Eclipse CDT中包含文件的相对路径

时间:2014-11-26 08:05:08

标签: eclipse eclipse-cdt

结构就是这样:

subsystem
  sub_dir
  sub_dir
  ...
  new_sub_dir_for _unit_test_which_includes_eclipse_workspace 
     Debug       <===   this, I think, being  ${workspace_loc} 
                        or is the parent directory ${workspace_loc}?
                        (since it contains .project and  .cproject)
     test_cases
     stubs
  file_1.c
  file_1.h
  file_1.c
  file_1.h
  ...
  software_under_test.c
  software_under_test.h

software_under_test.c#include "../somefile.h",显然不属于这个子系统。

当我使用Properties/C & C++ general/paths and symbols设置包含路径时,我似乎无法使用相对路径,只能使用绝对路径,我不想这样做,因为我希望其他人能够构建这个项目在他们的机器上和路径的起点可能因用户而异。

我确实尝试添加${workspace_loc}../及其变体,但我无法让它发挥作用。

我做错了什么?

1 个答案:

答案 0 :(得分:2)

您在浏览位置时是否使用变量选项?

在CDT项目中添加包含文件路径(项目属性/ C / C ++常规/路径和符号)时,有3个选项可以浏览位置:

  • 变量
  • 工作区
  • 文件系统

选择“工作区”选项,路径将相对于工作区/项目。选择Variables选项,您将使用${WorkspaceDirPath}等变量。您甚至应该能够引用环境变量。

相关问题