#including a header from the previous directory (../)
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
精彩评论