开发者

how to include header files in other src folder

I have a c++ project having two src folders. Source file in folder 1 may need to include header file in src folder 2. Is it possible? or how should 开发者_如何学PythonI write my Makefiles? thanks


Depending on how closely the two folders are related (eg, if they're the same project), then it can be as easy as:

#include "../otherfolder/header.h"

If they're separate projects, then it's customary to simply add the other project's header directory to your project's header search path, and include the header like this:

#include <header.h>

(In practice, the brackets/quotes don't matter, but it helps keep external vs. internal header imports separate)


Considering you have src1 and src2 folders in same folder. You have 2 solutions for this:

1 - #include "../src2/header.h"

2 - Add in your project at additional include directories src2 and use normal #include

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜