VC++ 2005 include list
While compiling a small piece of code, I noticed I had a typo on my very first line. Instead of #include <cstdlib>, I had #include <ctsdlib>.
To my awe there was no warning or error and even the expression system("pause") worked like a charm! It was obvious stdlib.h was somehow being included...
After much searching around I found a compiler option under C/C++/Advanced to show all the includes. I set it to yes and was simply amazed to see that despite what I have on my code, VC++ 2005 decides (rightly so) I don't know what I am doing. As such it is including every library imaginable everytime I compile even a simple console project.
iostream.h, istream.h, ios.h, sal.h, limits.h... you name it.
Thanks, but no thanks. Problem is I can't seem to find a way to turn this off. How do I tell VC++ 2005 to simply behave like a normal compiler and only work based on what's on my code? Even if that means it fails to compile.
it's been so long since i've used vc...if i had to guess, and i do, i would say look in that same general location (C/C++/Advanced)...possibly under anything that says libraries.
also, you might want to try looking at the arguments being pass to the compiler command line. i can't tell you much about what should and shouldn't be there (in the command line), but it might give you some insight to your troubles....
...sorry i didn't help at all
Chances are that the file you include includes other files which in turn includes other files again and so on.
I agree, you'll probably find these files if you look in the include files that you do include.
Still, shouldn't it give you an error? VS 2003 gives this:
fatal error C1083: Cannot open include file: 'ctsdlib': No such file or directory
with your original problem, (including <ctsdlib>) chances are that the file you changed wasn't rebuilt for some reason. as for system("pause") working, if you run (not debug, run) a console project from visual studio it puts a pause at the end anyway.
as for the masses of includes, look in you iostream file. if it's anything like the vs 2003 verison, it'll
which includes ostream
which includes ios
which includes cerrno
which includes limits.h
which includes stdio.h
you get the idea...
In fact the problem is with the #include <iostream> statement. Thanks.
I really don't want to write code like the below one and have it compile just fine. Which is exactly what is happening right now.
Is there anyway I can alter this behavior? String and cstdlib should have been explicitily included for that code to compile. However, they weren't and it compiled just fine due to iostream dependencies(?).
I've ran the above code on Bloodshed Dev-C++ and it also compiled just fine. I'm confused.
Is this expected behavior?
It is not 'expected' but it is understood that it is likely to happen. For example, in iostream, cout has << and >> overloaded for many different types. One of these is std::basic_string<> and std::string is basically a typedef for std::basic_string<char>; therefore, including whichever file in which std::basic_string<> is defined results logically in including its typedef's. I hope it makes sense to you. ;)
Yes, I understood. Thanks :)
I've found similar errors in VC 2005. I believe it often fails to flag your current file as dirty, or needing to be recompiled rather than use the pre-compiled header. This means that when you build it, it will not add your changes in. To make matters worse they have added the view old code or view dead code option which allows you to view the code as it was on your last compile.
I'm sure there will be some patches coming out soon. As it stands now VC 2005 is extremely shaky, the help system takes forever to load up in an external window, and it crashes frequently as well as causes memory leaks the longer it runs.
And all this slowness on a drive daily defragged by DiskKeeper 10 with an average of 1.0 fragments per file and 0 files reported as performing badly.
I look for updates very soon.