Header file declaration differences

Jun 1, 2010 at 6:44pm
Hi all,

I have been confused about this for a long time now.. What is the difference between double quotation marks and inequality brackets when including a header file? I believe the double quotation marks are used when the header file is located in the same directory, correct me if I'm wrong. Also, How does the compiler know where to find the header files if the path is not specified? Thanks in advance for the clarification!

-Ian
Jun 1, 2010 at 6:45pm
Here is what I mean:

include "header.h" VS. include <header.h>
Jun 1, 2010 at 6:47pm
I believe the double quotation marks are used when the header file is located in the same directory, correct me if I'm wrong

That's correct. And you use <> when the file is located in one of the include paths. By default this is /usr/include or /path/to/your/compiler/include on Windows. But you can add more if necessary.
Jun 1, 2010 at 7:56pm
Angle brackets (<>) tell the compiler to search the system include path first.
Double quotes ("") tell the compiler to search the user-specified include path first.

In general you use double quotes for headers you write and angle brackets for headers
that are part of 3rd party libraries / compiler libraries / etc.
Jun 1, 2010 at 8:00pm
When using angle brackets, the compiler will only search the include paths, not the current directory.
Jun 1, 2010 at 9:31pm
I see.. thanks guys :)

-Ian
Topic archived. No new replies allowed.