是否可以使用某种路径进行 #include
Is it possible to use some sort of path for #include?
我在文件中有一堆 #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"
?
通常,编译器会提供一个选项,您可以在其中添加路径,以便从#include
语句中查找头文件。
例如,对于海湾合作委员会添加
-I/Users/cooper/Desktop/MyLib
到编译器命令行。
此选项也可以设置在 IDE 的项目设置中,或作为生成系统中的变量进行设置。
相关文章:
- 如何将更多文件夹添加到c++include路径
- 对于MacOS上的G++,如何添加默认的include目录/usr/local/include和默认的库搜索路径/usr
- 如何在 c++ 中正确指定 #include 路径以使程序可移植
- 修改生成文件以简化框架 #include 路径
- 添加 #include 的搜索路径
- 为什么"/usr/include"不在 GCC 默认搜索路径中
- CMake导出的库-在客户端应用程序中找不到include/Lib路径
- 如何设置 CMake 来构建包含路径包含的代码,如 #include < libdir/lib>?
- 包含一批库和目录路径以"Include Additional Directories"视觉C++的任意方法
- 获取Qt项目所需的所有include路径、lib等
- 您如何为Sparx企业架构师逆向工程设置 #include 路径
- visualstudio目录和include路径
- 为最简单的项目生成的EclipseCDT构建并没有正确设置include路径
- 实际需要的#include路径更长
- Visual Studio 2010 C++是否可以从引用的项目继承include路径
- swig接口文件的正确sstream include路径是什么
- mErrCount:虽然在项目属性的include路径中声明了标识符,但未找到该标识符
- 阻止Apple clang在标准include路径中添加Xcode路径
- 处理不同平台上的#include路径
- 为c++在Eclipse中添加Boost - include路径问题