VC++ 2005 include list

This is a discussion on VC++ 2005 include list within the C++ Programming forums, part of the General Programming Boards category; While compiling a small piece of code, I noticed I had a typo on my very first line. Instead of ...

  1. #1
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,577

    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.

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    35
    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

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    903
    Chances are that the file you include includes other files which in turn includes other files again and so on.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    I agree, you'll probably find these files if you look in the include files that you do include.

  5. #5
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Still, shouldn't it give you an error? VS 2003 gives this:
    Code:
    fatal error C1083: Cannot open include file: 'ctsdlib': No such file or directory
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  6. #6
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    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
    include istream
    which includes ostream
    which includes ios
    which includes cerrno
    and xlocnum
    which includes limits.h
    and cstdio
    which includes stdio.h

    you get the idea...
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,577
    Thanks everyone,

    In fact the problem is with the #include <iostream> statement. Thanks.

    But...

    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.

    Code:
    #include <iostream>
    
    int main()
    {
            std::string aString("Hello");
    	system("pause");
    	return EXIT_SUCCESS;
    }
    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?

  8. #8
    Registered User
    Join Date
    May 2006
    Posts
    903
    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.

  9. #9
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,577
    Yes, I understood. Thanks

  10. #10
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with linked list ADT and incomplete structure
    By prawntoast in forum C Programming
    Replies: 1
    Last Post: 04-30-2005, 02:29 AM
  2. to #include or not to #include
    By krygen in forum C++ Programming
    Replies: 9
    Last Post: 12-25-2004, 12:06 AM
  3. Big help in Astar search code...
    By alvifarooq in forum C++ Programming
    Replies: 6
    Last Post: 09-24-2004, 12:38 PM
  4. Read and write hanging
    By zee in forum C Programming
    Replies: 8
    Last Post: 08-04-2004, 12:19 AM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 11:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21