中文
注册

Clang不支持在使用'-o'指定输出时直接添加头文件

错误信息

clang test.h test.c -o test 
clang-10: error: cannot specify -o when generating multiple output files

问题介绍

Clang不支持在使用'-o'指定输出文件时直接添加头文件,但允许在编译命令中使用预编译头文件,以减少编译时间。

$ cat test.c  
#include "test.h"

生成预编译头文件的命令:

clang -x c-header test.h -o test.h.pch 

可以通过添加 '-include' 命令使用预编译头文件:

clang -include test.h test.c -o test

Clang会先检查test.h对应的预编译头文件是否存在;如果存在,则会使用对应的预编译头文件对test.h进行处理,否则,Clang会直接处理test.h的内容。

如果设法在Clang编译命令中保留头文件,则可以通过添加命令'-include'的方法使其通过编译。

官方参考文档:https://clang.llvm.org/docs/UsersManual.html

解决方案

避免在 Clang 的编译命令中直接添加头文件,或者按照上述方法使用预编译功能。

搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词