当使用 Cmakes 时,target_precompile_headers我们会遇到很多重定义错误,例如
/usr/include/c++/8/bits/stringfwd.h:70:37: error: redefinition of default argument for \xe2\x80\x98class _Traits\xe2\x80\x99\n/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h:21:3: error: conflicting declaration \xe2\x80\x98typedef struct __mbstate_t __mbstate_t\xe2\x80\x99\n/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:28:8: error: redefinition of \xe2\x80\x98struct __locale_struct\xe2\x80\x99\n/usr/include/c++/8/bits/postypes.h:112:7: error: redefinition of \xe2\x80\x98class std::fpos<_StateT>\xe2\x80\x99\n/usr/include/c++/8/bits/postypes.h:216:1: error: redefinition of \xe2\x80\x98template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&)\xe2\x80\x99\n/usr/include/c++/8/bits/postypes.h:221:1: error: redefinition of \xe2\x80\x98template<class _StateT> bool std::operator!=(const std::fpos<_StateT>&, const std::fpos<_StateT>&)\xe2\x80\x99\n/usr/include/c++/8/iosfwd:76:70: error: redefinition of default argument for \xe2\x80\x98class _Traits\xe2\x80\x99\n/usr/include/c++/8/iosfwd:79:70: error: redefinition of default argument for \xe2\x80\x98class _Traits\xe2\x80\x99\n/usr/include/c++/8/iosfwd:82:70: error: redefinition of default argument for \xe2\x80\x98class _Traits\xe2\x80\x99\nRun Code Online (Sandbox Code Playgroud)\n以及无数其他的,全部来自 std 库函数。 …