开发者

#including a header from the previous directory (../)

开发者 https://www.devze.com 2023-01-23 14:57 出处:网络
Here is what I\'m trying to do. I have a folder called Agui which is the lib\'s folder. In that folder there is another folder called Widgets. I want a file from Agui/Widge开发者_运维知识库ts to #inc

Here is what I'm trying to do.

I have a folder called Agui which is the lib's folder. In that folder there is another folder called Widgets. I want a file from Agui/Widge开发者_运维知识库ts to #include base.h from Agui folder. How should I do this so that it remains cross platform? Should I simply include <Agui/base.h> ?

Thanks


#include "../base.h". And yes, that is portable.


You can use:

#include "../base.h"

From your Agui/Widgets folder. It should work. It should be cross platform.


Better is

#include "Agui/base.h"

or

#include "../base.h"

depending of whether your library root or current folder are added to the include search path.

Angle brackets are reserved for system libraries (although one can actually use any kind of them).


Its better to have the path setup in $PATH and in $LD_LIBRARY_PATH. By doing the above, you can just refer to the header file :

#include <base.h>

This will help to configure/run in any platform

0

精彩评论

暂无评论...
验证码 换一张
取 消