【发布时间】:2010-03-29 21:16:14
【问题描述】:
这是否意味着在上一个文件夹中搜索 somefile.h 或在项目文件夹中搜索 somefile.h?
【问题讨论】:
-
永远不要在新代码中使用它,如果可以在旧代码中更改它。使用相对路径(../whatever)存在严重的可扩展性问题。
标签: c++ include c-preprocessor
这是否意味着在上一个文件夹中搜索 somefile.h 或在项目文件夹中搜索 somefile.h?
【问题讨论】:
标签: c++ include c-preprocessor
这意味着在找到包含指令的源文件的父文件夹中查找somefile.h。
在 *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/ 中查找somefile.h
【讨论】:
这意味着在父目录中查找“somefile.h”,相对于包含指令的文件所在的目录。
【讨论】:
表示源文件所在目录的父目录。
【讨论】:
好吧,如果您的源文件在/src 中,那么somefile.h 应该高于src 或/
【讨论】: