Archived

This topic is now archived and is closed to further replies.

OberonZ

VC6 STL compilation problems

Recommended Posts

Grrr! So, I''m using VC6 and since I want the compiler to do as much work for me as possible, I''m compiling my project at the highest warning level (level 4). This is all fine and dandy until I try to use some of the standard library include files. If I include instead of , under warning level 4 I get (count ''em) 244 warnings! No warning with it''s counterpart... Now I''m just adding a .h to all the STL includes, but does anyone know why this happens? I took a look at the two file and they are completely different. Plus I''d rather get a eat lead paint chips that try to "debug" the VC version of the STL headers. sigh... -OberonZ ---
PAGE FAULT: Please insert "Swap File, Disk 2"
and press any key to continue.

Share this post


Link to post
Share on other sites
The <fstream> form of the header has all the functions in namespace std, could that be your problem? If so just whack std:: on the start of all your function calls or look up info on "using" declarations.

PS. you need to use code tags around #includes or replace the "<"s with "&lt;", or the filename gets interpreted as a HTML tag by the board software .

Edited by - Krunk on February 18, 2002 1:09:43 PM

Share this post


Link to post
Share on other sites
quote:
Original post by OberonZ
So, I'm using VC6 and since I want the compiler to do as much work for me as possible, I'm compiling my project at the highest warning level (level 4). This is all fine and dandy until I try to use some of the standard library include files.

If I include <fstream> instead of <fstream.h>, under warning level 4 I get (count 'em) 244 warnings! No warning with it's counterpart...



This is down to Microsoft bogosity. The compiler can't create debug symbols longer than 256 bytes, and truncates them. Previously, it's been quite rare to get debug symbols that long, but it happens with template code. <fstream> contains template code. You can switch off specific warnings using #pragma warning( disable : nnnn ).

quote:

Now I'm just adding a .h to all the STL includes, but does anyone know why this happens? I took a look at the two file and they are completely different. Plus I'd rather get a eat lead paint chips that try to "debug" the VC version of the STL headers. sigh...



You can't add a ".h" to the STL includes, as they won't be STL includes if you do. For instance, there is no <vector.h> header under STL or MS. fstream isn't actually part of the STL, but you still shouldn't be adding a ".h" to it. Use the proper headers, and switch off the warnings you're not interested in.

--
The Dilbert Principle: People are idiots.


Edited by - SabreMan on February 18, 2002 1:05:58 PM

Share this post


Link to post
Share on other sites
Thanks for your replies,

Krunk: when using <fstream>, I am prefixing the ofstream with std::. And thanks for the html head''s up I hadn''t noticed.

SabreMan: I''m getting warnings like:
unreferenced formal parameter
copy constructor could not be generated
assignment operator could not be generated
C++ language change: to explicitly specialize class template ''identifier'' use the following syntax: ...

I can disable these (and I did) except that #pragma warning (disable:xxxx) doesn''t seem to be global since I still get the last warning in other files I didn''t include (that I''m assuming are included by <fstream>, files like xmemory.h. Do you know how to disable warnings on a global scale? (btw, I disabled the warning at the top of my main cpp file, before any headers were included)

I know here isn''t a vector.h thankfully that file has no problems.

What is bogosity?

Thanks again,
-OberonZ

Share this post


Link to post
Share on other sites
quote:
Original post by OberonZ
SabreMan: I''m getting warnings like:
unreferenced formal parameter
copy constructor could not be generated
assignment operator could not be generated
C++ language change: to explicitly specialize class template ''identifier'' use the following syntax: ...


Hmmm... those weren''t the warnings I was thinking of, but I do remember getting several different spurious warnings from VC++ on warning level 4, so I''m hardly surprised. I eventually decided that warning level 4 was more trouble than it''s worth.

quote:

I can disable these (and I did) except that #pragma warning (disable:xxxx) doesn''t seem to be global since I still get the last warning in other files I didn''t include (that I''m assuming are included by , files like xmemory.h. Do you know how to disable warnings on a global scale?


I don''t think you can. #pragma warning is only for effective for the translation unit it appears in.

quote:

What is bogosity?


The state of being bogus.

--
The Dilbert Principle: People are idiots.

Share this post


Link to post
Share on other sites
Look up the push and pop versions of the #pragma warning directive, and use these to edit your STL headers so that they use level 3 while being compiled. I posted a thread about this a little while ago, but I can''t find it.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]

Share this post


Link to post
Share on other sites