-2

Possible Duplicate:
What is the difference between #include <filename> and #include “filename”?

I just got involved into a project.

When I were tracing the project code, I found that

some people can include a header file by this way:

include < XXX.h >

XXX.h is a header file that is not in system libraries and made by our own programmers...

My question is how to use '<' and '>' instead of double " ?

and how to include headers in other directories by this way?

for example:

headers/header_a.h headers/header_b.h

I can use include < header_a.h > and < header_b.h >...

should I use Makefile to implement this? thanks..

Community
  • 1
  • 1
Jarkid
  • 171
  • 1
  • 4
  • 13
  • 3
    And the answer is, you don't. You use <> for system includes and "" for your files because that is how they are intended to be used. – Ed S. Apr 13 '12 at 02:14

2 Answers2

2

A file in double-quotes is referenced relative to the current directory:

#include "../file.h" // file from parent directory

You'd generally use this for your own headers.


A file in angle-brackets is referenced relative to the paths specified to the compiler:

#include <sys/bits.h> // file under, e.g.,  /usr/include
#include <thirdpartytools/somelib.h> // file under /path/to/third/party/includes

You'd generally use this for system or perhaps third-party headers, assuming the compiler is invoked with something like

gcc -I/usr/include -I/path/to/third/party/includes ...
Adam Liss
  • 47,594
  • 12
  • 108
  • 150
0

The <> usually denotes System headers and the "" usually denote header files in the current directory (usually your header files). Source/Reference here for more info: Difference between angle bracket < > and double quotes " " while including header files in C++?

Community
  • 1
  • 1
Youssef G.
  • 617
  • 4
  • 10