#include"../somefile.h"中的..是什么意思

Mar*_*lon 3 c++ include c-preprocessor

是否意味着搜索somefile.h的上一个文件夹或somefile.h的项目文件夹?

Ara*_*raK 14

这意味着somefile.h在父文件夹中查找找到include指令的源文件.

在*nix系统中(这个约定来自AFAIK):

.        manse the current directory.
..       means one level up from the current directory.
Run Code Online (Sandbox Code Playgroud)

例如,如果您具有以下目录结构:

home
   |
   code
      | src
      | someOtherDirectory
Run Code Online (Sandbox Code Playgroud)

你的源文件可能在home/code/src,你有:

#include "../somefile.h"
Run Code Online (Sandbox Code Playgroud)

在你的源代码,那么编译器会寻找somefile.hhome/code/

  • 次要注意 - 标准不要求这是".."的含义,它实际上在几乎任何文件系统中都意味着什么. (2认同)