0

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

I am creating a shared C library. Is there any difference when including

#include <mylib/someheader.h>

versus

#include "mylib/someheader.h"

from *.c or *.h files of this library?

Community
  • 1
  • 1
Cartesius00
  • 23,584
  • 43
  • 124
  • 195
  • You use quotes when it is your own header file. – squiguy Aug 01 '12 at 19:30
  • Also, it makes large projects much more readable if you leave out the path of the header and include just the name. You can specify additional include directories for gcc with the -I flag, like such: `gcc -c somefile.c -o someobj.o -I ./mylib` – Wug Aug 01 '12 at 19:32
  • @Wug: This could cause nasty collisions. – Cartesius00 Aug 01 '12 at 19:33
  • @James its a large project thing. Every large project does it this way. It should only cause nasty collisions if you do nasty things like have multiple headers with the same name anyway, so if you get collisions its your own darn fault. – Wug Aug 01 '12 at 19:35
  • Also ohey, there is an option to modify just the path that "" includes search for: `gcc -c somefile.c -o someobj.o -iquote ./mylib` – Wug Aug 01 '12 at 19:41
  • @Wug: No, when developing shared library, exported headers could cause collisions with the executable, when not using prefixes. – Cartesius00 Aug 01 '12 at 19:43

2 Answers2

1

The first version is used for system headers, the second for external headers. Most compilers will find the right header, whatever the notation, though.

LodeRunner
  • 7,975
  • 3
  • 22
  • 24
  • 2
    I believe both will search the same places, and the difference is that <> searches library locations first and "" searches user locations first. – Wug Aug 01 '12 at 19:33
  • 1
    And so basically, if this concerns gcc, there's always the option of reading the manual: http://gcc.gnu.org/onlinedocs/gcc-4.7.1/cpp/Include-Syntax.html – LodeRunner Aug 01 '12 at 19:35
0

Depends on compiler. Some of them can differ between "system" include path and "just" include path. <> denotes system include path

Roman Saveljev
  • 2,544
  • 1
  • 21
  • 20