Results 1 to 4 of 4

Thread: [RESOLVED] Including header files.

  1. #1

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Resolved [RESOLVED] Including header files.

    Say I have a header file named as "Complex.h"

    On .cpp I want to include it. So I test it on following three ways.

    1. #include "Complex.h"
    2. #include ".\complex.h"
    3. #include "complex.h"


    In all ways it works fine. So that means there is no any different between above three line?

    When I use IDE to add classes to my applications, the header files are included as the second way.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  2. #2

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: Including header files.

    Seems to me header file name is case insensitive, and first of all header file is searching on the current working folder. If not where it search, include directory of compiler?
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  3. #3
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Including header files.

    Different compilers work mostly the same way.. the generic way they process what files to include is like this:

    1) If the header file has quotes around it.. search in the current directory. So, for example: You have directory called "MyProgram". A subdirectory in that folder, is "include". If your file "main.cpp" in "MyProgram" tries to include the file "headerfile.h" in "MyProgram\include", it won't work. But, if you move main.cpp into \include, then it will work. Or, you could use "#include include\headerfile.h".

    2) If it can't find it.. check compiler include directories.

    3) Still can't find it.. throw an error.

    4) If it has bent brackets around it <>, check compiler include directories only.

    5) Can't find it.. throw an error.

    Visual Studio 6, Visual Studio.NET 2005, MASM

  4. #4

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: Including header files.

    I got it Chem. Thanks.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width