1

Do quotes in library include path in C++ mean base directory?

#include "header.h"

I would think it would be in the project folder, but I am wrong.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Steven Hammons
  • 1,774
  • 8
  • 24
  • 33
  • Related question: http://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename – Fred Larson Mar 15 '11 at 05:39
  • It is **very** related to the linked question. :-) The language standard doesn't contain anything about paths (some systems don't have any!), so it cannot define how files are searched for. It is all implementation defined. – Bo Persson Mar 15 '11 at 05:45

2 Answers2

1

#include <foo.h> means that it will look for the file anywhere in the include path.

#include "foo.h" means to look relative to the directory of the file that the #include statement is written in, and fallback on the include path if it cannot be found locally.

Nathan Ostgard
  • 8,258
  • 2
  • 27
  • 19
1

That will only look in the directory of the file. ie if you had the following setup:

folder: src
contents: header.c

folder: src/include
contents: header.h

If you had the line above in header.c, the preprocessor would not find the header.h file.

themaestro
  • 13,750
  • 20
  • 56
  • 75