代码之家  ›  专栏  ›  技术社区  ›  Marlon

什么..包括“./somefile.h”是指

  •  3
  • Marlon  · 技术社区  · 16 年前

    这是指在前一个文件夹中搜索somefile.h还是在项目文件夹中搜索somefile.h?

    4 回复  |  直到 10 年前
        1
  •  14
  •   Khaled Alshaya    16 年前

    意思是寻找 somefile.h 与找到include指令的源文件相关的父文件夹中。

    在*nix系统中(这是本公约来自afaik的地方):

    .        manse the current directory.
    ..       means one level up from the current directory.
    

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

    home
       |
       code
          | src
          | someOtherDirectory
    

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

    #include "../somefile.h"
    

    在源代码中,编译器将查找 一些文件 在里面 home/code/

        2
  •  3
  •   ChrisF    16 年前

    这意味着在父目录中查找“somefile.h”,相对于包含指令的文件所在的目录。

        3
  •  2
  •   Ignacio Vazquez-Abrams    16 年前

    它表示源文件所在目录的父目录。

        4
  •  0
  •   Earlz    16 年前

    如果你的源文件在 /src 然后 somefile.h 应该在上面 src 或在 /