为什么可以找到stdint.h,但cstdint不能

Why do stdint.h can be found but cstdint not?

本文关键字:cstdint 不能 stdint 为什么      更新时间:2023-10-16

我很惊讶包括stdint.h作品,但不包括cstdint。

$ aCC sizeof.cpp
"sizeof.cpp", line 5: error #2005-D: could not open source file "cstdint"
  #include <cstdint>
                    ^
1 error detected in the compilation of "sizeof.cpp".
$ aCC --version
aCC: HP C/aC++ B3910B A.06.12 [Nov 03 2006]

这与 g++ 相同:

$ g++ --version
g++ (GCC) 4.2.3

请问为什么?而且,除了更新编译器之外,有什么方法可以解决此问题吗?谢谢。

您的编译器支持没有<cstdint>的旧C++标准(因为 C90 没有<stdint.h>)。 <cstdint>是 C++11 的新功能。