XCode 4 C ++头文件,具有到另一个头的相对路径 [英] XCode 4 C++ header file with relative path to another header
问题描述
我使用的库有一个include结构,其中.h文件都在一个单一的目录。这些.h文件包含一行,一个 #include
指令,指向特定源文件夹位置中的真实头文件。这些文件中的 #include
路径是相对的。
目录结构是:
/ project
/ sources
< my .cpp files>
< my .cpp文件>
...
/ include
/ component
foo1.h
foo2.h
/platformA/something/foo1.h
/ platformB / somethingelse / foo2.h
/include/component/foo1.h包含一行代码:
#include../ platformA / something / foo1.h
< component / foo2.h包含单行代码
#include../ platformB / somethingelse / foo2.h
在我的来源中,我只有:
#includecomponent / foo1.h
我的项目的标题搜索路径指向 / include
现在,XCode 4能够找到 / include
中的code> component / foo1.h ,但是无法跟踪这些标头中的相对include路径,
我怀疑这是因为顶层foo1.h文件中的include路径是相对于它的位置,但XCode可能会把它视为相对于一些其他位置(项目根或东西)? FWIW,Visual Studio没有相同配置的问题。
有什么想法可以解决这个问题吗?
从您的目录结构看,目录 platformA
和 platformB
放在include文件夹之外。有两种可能的解决方案:
解决方案A
移动这些
至包含
文件夹。
解决方案B
添加
project / platformA
和
project / platformB
到
目录,其中包含文件
。
应在项目
设置中查找
I'm using a library with an include structure where the .h files are all in a single directory. These .h files contains a single line, a #include
directive which points to the 'real' header file in specific source folder locations. The #include
path in these files is relative.
So, here's an example. The directory structure is:
/project
/sources
<my .cpp files>
<my .cpp files>
...
/include
/component
foo1.h
foo2.h
/platformA/something/foo1.h
/platformB/somethingelse/foo2.h
/include/component/foo1.h contains a single line of code:
#include "../platformA/something/foo1.h"
/include/component/foo2.h contains the single line of code #include "../platformB/somethingelse/foo2.h"
In my sources, I simply have:
#include "component/foo1.h"
The header search path for my project points to /include
Now, XCode 4 is able to find component/foo1.h
in /include
, but it's unable to follow the relative include path within those headers and find the 'real' foo1.h in the `/platformA/something' directory, and so on.
I suspect it's because the include paths in the top-level foo1.h file is relative to its location, but XCode might be treating it as relative to some other location (project root or something)? FWIW, Visual Studio has no problems with an identical configuration.
Any ideas on what I can do to remedy this?
From your directory structure it seems that the directories platformA
and platformB
are placed outside the include folder. There are two possible solutions to this:
Solution A
Move these to
include
folder.
Solution B
Add
project/platformA
andproject/platformB
to thedirectories where include files should be looked for
in project settings.
这篇关于XCode 4 C ++头文件,具有到另一个头的相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!