如何在其他src文件夹中包含头文件
我有一个带有两个src文件夹的c ++项目.文件夹1中的源文件可能需要在src文件夹2中包含头文件.可能吗?还是应该如何编写我的Makefile?谢谢
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 I 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)