fstream & compilation in Visual C++ under .NET 2003

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If I try to declare an object of type fstream (or ofstream), I run into a compilation error refering to an __something function or variable.

Please note, I am including <fstream>, not <fstream.h>. I do know that much.

Thanks in advance for any assistance.

John
 
John said:
If I try to declare an object of type fstream (or ofstream), I run
into a compilation error refering to an __something function or
variable.

Please note, I am including <fstream>, not <fstream.h>. I do know
that much.

Thanks in advance for any assistance.

Please give some example code and/or the complete text of an error message.

-cd
 
The error message is "error C2061: syntax error: identifier '_DebugHeapTag'". It occurs when building the project's precompiled header file.

Once I realized this was not simply a case of some oversight on my part (e.g., the fopen "b" argument) or a known bug, I did build a ~10 line project focused on the problem. The error does not show up there. It could be that I have 1 of the 100's of build properties set differently in the test project than in the real project. If you can suggest any for me to fiddle with, I will.

I would take the more general approach of cutting down the real project until it was the minimum size that would produce the error but that could take a while. The real project runs ~200,000 SLOC with considerable interdependence among its many .h and .cpp files. If you can suggest something that would reduce the effort significantly, I will give it a try. Otherwise, I will simply use the C-style I/O functions (which work now), thanks to you.

Again with graditude and respect,

John Delaney

----- Carl Daniel [VC++ MVP] wrote: -----
If I try to declare an object of type fstream (or ofstream), I run
into a compilation error refering to an __something function or
variable.

Please give some example code and/or the complete text of an error message.

-cd
 
John said:
The error message is "error C2061: syntax error: identifier
'_DebugHeapTag'". It occurs when building the project's precompiled
header file.

Once I realized this was not simply a case of some oversight on my
part (e.g., the fopen "b" argument) or a known bug, I did build a ~10
line project focused on the problem. The error does not show up
there. It could be that I have 1 of the 100's of build properties set
differently in the test project than in the real project. If you can
suggest any for me to fiddle with, I will.

I would take the more general approach of cutting down the real
project until it was the minimum size that would produce the error
but that could take a while. The real project runs ~200,000 SLOC with
considerable interdependence among its many .h and .cpp files. If you
can suggest something that would reduce the effort significantly, I
will give it a try. Otherwise, I will simply use the C-style I/O
functions (which work now), thanks to you.

That's probably the better choice anyway - it'll be less work than retooling
a large codebase to use C++ streams. Unfortunately, I don't know of any
magic bullet for narrowing down a repro case other than the laborious method
you allude to. Checking the complete compiler options between your test
project and the production project is a reasonably simple thing to do and
might yield some answers, but I doubt it. More likely, the cause is a macro
that's interfering with the <iostream> header file somehow, so it's
dependent on exactly what's been included and in what order.

-cd
 
Back
Top