简体   繁体   English

OSX Eclipse CDT-根样式包括

[英]OSX Eclipse CDT - root style includes

In a C++ project, in Eclipse CDT, one point of contention that I often have is the pain of removal a file because of the way it handles includes. 在C ++项目中,在Eclipse CDT中,我经常遇到的一个争论点是,由于文件处理方式的原因,很难删除文件。 In Xcode, it is possible to use the file name, or name relative from the project directory however eclipse requires me to often have backwards ".." relative paths which can be difficult to read, track as the project grows in complexity. 在Xcode中,可以使用文件名,也可以使用项目目录中的相对名称,但是eclipse要求我经常使用向后的“ ..”相对路径,随着项目的复杂性增加,这些路径很难阅读和跟踪。

Includes currently look like this: 当前包括如下所示:

`../../model/geometry/Square.h`

Ideally i'd like to have all includes, pretend they are being called from the 'root of src directory' such as 理想情况下,我希望拥有所有包含项,假装它们是从“ src目录的根目录”中调用的,例如

`model/geometry/Square.h`

I understand that includes are essentially a preprocessor, find-replace instruction however this is 2012, there must be a way. 据我了解,包括本质上是一个预处理器,查找-替换指令,但这是2012年,必须有一种方法。

Of course there is a way of doing so : 当然有一种方法可以这样做:

Right click on your Project -> Properties -> Open the C/C++ General tab -> Path and Symbols -> select your language on the left (C++/C/Assembly) -> on the right, click on Add... And select your folder location! 右键单击项目->属性->打开C / C ++常规选项卡->路径和符号->在左侧选择您的语言(C ++ / C / Assembly)->在右侧,单击添加...,然后选择您的文件夹位置!

Hope it helped! 希望能有所帮助!

Edit: Remember that if you include a folder, you can then include the files which are in that particular folder directly 编辑:请记住,如果您包含一个文件夹,则可以直接包含该特定文件夹中的文件

#include "file.h" and not #include "folderIncluded/file.h"

Regards, Erwald 此致Erwald

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM