因此,使用这段人为的代码 - 使用 clang 编译工作得很好,但是当使用 ccache 时会出现额外的警告/错误 - 我认为 ccache 应该透明地传递这些。这是来自 epel repo 的 CentOS 6 上的 ccache 3.1.6 - 升级不是一个选项,因为这是生产环境。
#include <byteswap.h>
int main()
{
int i = 42;
auto j = bswap_32(i);
(void)j;
return 0;
}
因此,未使用包含路径的示例 1 没有给出错误:
clang++ -Wno-c++98-compat -Wall -Werror -std=c++17 -I/usr/local/include -c ccache.cpp
但是使用 ccache 我得到:
ccache clang++ -Wno-c++98-compat -Wall -Werror -std=c++17 -I/usr/include/xmlib -c ccache.cpp
clang-5.0: error: argument unused during compilation: '-I /usr/include/xmlib' [-Werror,-Wunused-command-line-argument]
没有额外包含的示例 2 可以正常工作:
clang++ -Wno-c++98-compat -Wall -Werror -std=c++17 -c ccache.cpp
和 ccache
cache clang++ -Wno-c++98-compat -Wall -Werror -std=c++17 -c ccache.cpp
ccache.cpp:6:32: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
auto j = (__extension__ ({ register unsigned int __v, __x = (i); if (__builtin_constant_p (__x)) __v = ((((__x) & 0xff000000) >> 24) | (((__x) & 0x00ff0000) >> 8) | (((__x) & 0x0000ff00) << 8) | (((__x) & 0x000000ff) << 24)); else __asm__ ("bswap %0" : "=r" (__v) : "0" (__x)); __v; }));
^~~~~~~~~
ccache.cpp:6:32: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
auto j = (__extension__ ({ register unsigned int __v, __x = (i); if (__builtin_constant_p (__x)) __v = ((((__x) & 0xff000000) >> 24) | (((__x) & 0x00ff0000) >> 8) | (((__x) & 0x0000ff00) << 8) | (((__x) & 0x000000ff) << 24)); else __asm__ ("bswap %0" : "=r" (__v) : "0" (__x)); __v; }));
^~~~~~~~~
2 errors generated.
为什么使用 ccache 会改变结果?