What's difference between #include< Unit1.h> and #include "Unit1.h "

What is the difference between including header files as

#include and
#include "Unit1.h"

I experienced a strange problem.
I used two forms in a application.
One form variables and components were used in other form.
So included the line #include in Form2.

The program was working fine.
Later I added one or more components in Form1(Unit1).
But I could not access the newly added components from Form2.
I then changed the line #include to #include "Unit1.h"
It was ok then....
I don'know why this happens.
What difference makes between including header files
the angle brackets < > and double quotes" ".
Can anyone explain what's behind the screen.

Comments

  • : What is the difference between including header files as
    :
    : #include and
    : #include "Unit1.h"
    :
    : I experienced a strange problem.
    : I used two forms in a application.
    : One form variables and components were used in other form.
    : So included the line #include in Form2.
    :
    : The program was working fine.
    : Later I added one or more components in Form1(Unit1).
    : But I could not access the newly added components from Form2.
    : I then changed the line #include to #include "Unit1.h"
    : It was ok then....
    : I don'know why this happens.
    : What difference makes between including header files
    : the angle brackets < > and double quotes" ".
    : Can anyone explain what's behind the screen.
    :
    :

    <> means that C++ will search include file in directories, you have written in Project->Options..->Directories/Conditionals->Include Path
    "" means C++ will search for them in current directory.
  • : What is the difference between including header files as
    : #include and
    : #include "Unit1.h"
    For #include questions see:
    http://www.codepedia.com/1/CCPlusPlusInclude

    : So included the line #include in Form2.
    This sounds like a double header guard exclusion!
    (See the link http://www.codepedia.com/1/define)

    In the beginning of Unit1 you have the header guard:

    #ifndef Unit1H
    #define Unit1H
    //Code
    #endif

    Unit2 has this as well. This might generate unread code when:

    //In Unit1
    #ifndef Unit1H
    #define Unit1H
    #include "Unit2.h" //Indeed, use ""'s
    #endif

    //In Unit2
    #ifndef Unit2H
    #define Unit2H
    #include "Unit1.h" //Indeed, use ""'s
    #endif

    What happens is that Unit1 #defines Unit1H, Unit1 #includes Unit2, Unit2 #defines Unit2H, Unit2 #includes Unit1, SKIPS Unit1 (as Unit1H is already #defined), DONE BUT NOT WHAT YOU WANTED!!!

    To solve this, use (I believe) 'File | Add Unit Header' with the different Units in focus.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories