c++ - g++ 使用自定义头文件编译

标签 c++ g++

我想使用头文件, 其包含为 #include <custom.h>

如何使用 custom.h 头文件编译它?

我试过了 -I /path/to/custom.h , 但它给我的错误是它不是一个目录..

最佳答案

-I /path/to

这将能够找到该目录中的所有 header 。

在 man gcc 中,搜索(在寻呼机中使用/)“-I dir”:

-I dir

Add the directory dir to the list of directories to be searched for header files. Directories named by -I are searched before the standard system include directories. If the directory dir is a standard system include directory, the option is ignored to ensure that the default search order for system directories and the special treatment of system headers are not defeated. If dir begins with "=", then the "=" will be replaced by the sysroot prefix; see --sysroot and -isysroot.

关于c++ - g++ 使用自定义头文件编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4067302/

相关文章:

c++ - g++ 可变参数模板问题

c++ - 检测/避免 g++ 符号冲突

c++ - 对未对齐的内存访问发出警告?

c++ - 如何在其他文件(foo.h、foo.cpp)中使用主文件 (main.cpp) 中的变量?

c++ - 将一个字符串流附加到另一个字符串流。什么最安全?

c++ - 默认构造函数中的歧义

c++ - 在 G++ 中访问相等比较运算符时出现歧义错误

c++ - 静态 boost.test 库和动态 boost.test 库

c++ - 我的 Makefile 或 C++ 程序有什么问题?

C++ 非常量-常量引用函数重载