开发者

How to put something in my "include path"?

开发者_开发技巧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>

?


Use the -I flag of the compiler. Like:

~$ c++ -Wall -Werror -pedantic -I/home/user/include -c source_file.cpp


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).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜