如何将某些内容放入我的“包含路径”中?
我将所有项目包含文件放在特定目录中(在我的项目目录中称为 include
)。当我将它们包含在 cpp 文件中时,我需要
#include "include/somefile.h"
如何制作才能做到这一点
#include <somefile.h>
?
I have all my project include files in a specific dir (called include
, in my project dir). When I include them in a cpp file, I need to
#include "include/somefile.h"
How can I make it so that I can do
#include <somefile.h>
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用编译器的
-I
标志。喜欢:Use the
-I
flag of the compiler. Like:使用双引号包含本地工作目录中的查找,而包含在尖括号中的包含告诉链接器/编译器在标准位置查找,例如 /usr/bin/ (在 *nix 平台上)。您可以使用 -I 编译器指令告诉它查看其他位置(至少对于 gcc/g++,像 Visual Studio 这样的 IDE 有自己的机制)。
Using double quotes to include looks within the local working directory, while includes wrapped in angle brackets tell the linker/compiler to look in standard locations such as /usr/bin/ (on *nix platforms). You can tell it to look other places with the -I compiler directive (with gcc/g++ at least, IDEs like Visual Studio have their own mechanisms).