我正在尝试将一些头文件编译成一个模块,这样我就可以使用这个编译器选项测试它是否有效:
g++ -fmodules-ts -std=c++20 -c -x c++-system-header <file-name>
其中<file-name>是标题的名称,例如string_view.
但是,并非所有头文件都能和谐地工作,这是无法编译的头文件列表,其中包含常见错误,例如 , 的导入宏定义不一致NULL,__stdcall指向类的递归延迟加载allocator,以及在范围内找不到的 I/O 函数,例如vsnprintf. 一些错误通常指向<pthread.h>和<process.h>c-headers。
<bitset><memory_resource><stdexcept><system_error><string><iterator><ranges><algorithm><execution><complex><random><locale><ios><istream><ostream><iostream><fstream><sstream><syncstream><iomanip><streambuf><filesystem><regex><thread><stop_token><mutex><shared_mutex><future><condition_variable><span>
上面没有提到的headers编译成功。
注意:我使用的是 GCC 11.1 版。
更新
有些头文件是我自己解决的,唯一不能编译的头文件是:
<execution><locale><iomanip><filesystem><thread><stop_token><condition_variable>
正如我在第一个上面提到的,他们共享的唯一常见错误是不一致的导入宏定义NULL