【发布时间】:2016-07-10 10:54:26
【问题描述】:
我在文件中有一堆#include 语句:
#include "/Users/cooper/Desktop/MyLib/graph_api.h"
#include "/Users/cooper/Desktop/MyLib/mst.h"
#include "/Users/cooper/Desktop/MyLib/dfs.h"
#include "/Users/cooper/Desktop/MyLib/bfs.h"
#include "/Users/cooper/Desktop/MyLib/topo_sort.h"
#include "/Users/cooper/Desktop/MyLib/scc.h"
#include "/Users/cooper/Desktop/MyLib/bipartite.h"
#include "/Users/cooper/Desktop/MyLib/dijkstra.h"
#include "/Users/cooper/Desktop/MyLib/union_find.h"
#include "/Users/cooper/Desktop/MyLib/my_string.h"
#include "/Users/cooper/Desktop/MyLib/2d_array.h"
不过,它可能会在未来发生变化,我将不得不更新一些行。有没有可能有类似的东西
PATH = "/Users/cooper/Desktop/MyLib/
#include PATH + "2d_array.h"
?
【问题讨论】:
-
它本身不是 makefile 的一部分。它是一个命令行选项。 Makefile 只是管理编译的一种机制
-
看起来您使用的是 OSX 系统(根据路径判断),这意味着您可能正在使用 Xcode。在项目设置中必须有一个可以输入预处理器设置的地方,例如添加包含路径。如果你这样做,并添加
/Users/cooper/Desktop/MyLib,那么你可以简单地做#include <2d_array.h>。 -
this answer 应该对你有用。 (我的意思是写
#define PATH "/Users/cooper/Desktop/MyLib/和#include PATH "2d_array.h") -
我正在使用 XCode,对。
标签: c++