为什么<sys/types.h>中的uint使用-std = c99消失?

Alb*_*ymk 4 c standards c99

// Filename: test.c
#include <sys/types.h>
int main() {
    uint a;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

上面的代码能够使用gcc和clang编译,标准如gnu89或gnu99.换句话说,以下工作.

$gcc test.c # for the default is std=gnu89
$clang test.c # for the default is std=gnu99
Run Code Online (Sandbox Code Playgroud)

但是,以下错误导致错误"未声明的uint".

$gcc -std=c99 test.c
$clang -std=c99 test.c
Run Code Online (Sandbox Code Playgroud)

有人可以解释为什么uint的定义在c99标准中消失了吗?

小智 6

因为C标准没有定义/要求类型uint.它很可能是编译器,系统或库特定的便利类型.不要使用它.