#include directive: relative to where?

前端 未结 6 1635
小鲜肉
小鲜肉 2021-02-05 00:05

I have looked in The C++ Programming Language to try to find the answer to this. When I #include \"my_dir/my_header.hpp\" in a header, where does it look f

6条回答
  •  渐次进展
    2021-02-05 00:28

    Its implementation defined. Those #include"my_dir/xxy.hpp" on a file (for example foo.h) are relative to the file (foo.h and my_dir would be on the same level at the directory hierarchy). With some (most?) compilers, you can use a flag to use these < > (#include

    I know that gcc / g++ provides the -I flag. So you could use g++ -I /home [...] indicating that the xxy.hpp file is located in the /home/my_dir/ directory. I havent used any other C/C++ compiler in a while now.

提交回复
热议问题