C ++: # enable file search?

This MSDN document cites:

look for the included files in the same directory of the file that the #include statement contains and then in the directories of any files that include (#include) this file

Wait what? What does this mean (bold)?

+3
source share
3 answers

This probably means that if it foo/bar/baz.cincludes ../bog/bog.h, and the latter contains

#include "fix.h"

he will find foo/bar/fix.h. In other words, it looks in a directory containing a C file that contains a header containing include. Clear? :)

, , ASCII, :

  foo/
  |
  +-bar/
  | |
  | +-baz.c
  | |
  | +-fix.h
  |
  +-bog/
    |
    +-bog.h

bog.h fix.h sibling foo.

+5

, , foo.h, bar.cpp, baz.cpp .., #include "somefile.h" foo.h, bar.cpp baz.cpp .

+1

, MSDN.

, , , "" . - , #include. , file2 file1, 1 .

""; #include , #include. , 2, , 3. file1 2, "" file3.

, . , , . , , /I. , , INCLUDE.

+1

Source: https://habr.com/ru/post/1725701/


All Articles