#include problem

This is a discussion on #include problem within the C++ Programming forums, part of the General Programming Boards category; Hi I am using MS Visual studio 08. I had a pretty big Cpp file and so I copied all ...

  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
    21,311
    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).
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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,185
    < > 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
    21,311
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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, 05:23 AM
  3. include problem
    By Strait in forum C++ Programming
    Replies: 4
    Last Post: 01-31-2005, 03: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, 12:21 PM

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