Thread: #include problem

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    224

    Wink #include problem

    Hi

    I am using MS Visual studio 08.

    I had a pretty big Cpp file and so I copied all the #include using namespaces and #defines into a seperate header file by adding a header file in the solution explorer.

    I then proceeded to call the header file: #include<"headerfile.h">

    Howver, I am getting an error and it is bugging me cos I dont know why.

    This error says,
    there is no such file or directory

    Can anyone please help?

    Thanks

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    It looks like you actually want to #include "headerfile.h"

    By the way, header files should not have using directives or using declarations (except in special cases within a restricted scope).
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    224
    Brilliant,

    Can you clarify what the < > (or lack the of) achieves in this instance.

    Thanks

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    < > says "this is a system header", and therefore the system will look in the directory with all the system headers. " " says "this is my header", so the system will look in your directory. <" "> says "I have a system header whose name has quotes in it", which is almost certainly false.

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Can you clarify what the < > (or lack the of) achieves in this instance.
    Generally, #include <header> is used when header is a standard header or in your compiler's include directory. #include "header" is used otherwise, where the header is searched with respect to the current directory of the file including it (or with respect to any directories designated by some compiler option as containing files for inclusion). If #include "header" fails, the compiler will try again as if it were #include <header>.

    Strictly speaking, the locations where the compiler will search for the headers in both cases is implementation defined, but this is what is typically the case.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with simple socket client/server program
    By spencer88 in forum C Programming
    Replies: 6
    Last Post: 05-05-2009, 11:05 PM
  2. debug assertion failed!
    By chintugavali in forum C Programming
    Replies: 4
    Last Post: 12-11-2007, 06:23 AM
  3. include problem
    By Strait in forum C++ Programming
    Replies: 4
    Last Post: 01-31-2005, 04:01 PM
  4. Read and write hanging
    By zee in forum C Programming
    Replies: 8
    Last Post: 08-03-2004, 11:19 PM
  5. help with finding lowest number entered
    By volk in forum C++ Programming
    Replies: 12
    Last Post: 03-22-2003, 01:21 PM