簡體   English   中英

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

[英]Why uint from <sys/types.h> disappears using -std=c99?

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

上面的代碼能夠使用gcc和clang編譯,標准如gnu89或gnu99。 換句話說,以下工作。

$gcc test.c # for the default is std=gnu89
$clang test.c # for the default is std=gnu99

但是,以下錯誤導致錯誤“未聲明的uint”。

$gcc -std=c99 test.c
$clang -std=c99 test.c

有人可以解釋為什么uint的定義在c99標准中消失了嗎?

因為C標准沒有定義/要求類型uint 它很可能是編譯器,系統或庫特定的便利類型。 不要使用它。

這里顯示的內容,與uint相關的部分介紹如下:

#ifdef __USE_MISC
/* Old compatibility names for C types.  */
typedef unsigned long int ulong;
typedef unsigned short int ushort;
typedef unsigned int uint;
#endif

這個SO告訴我們這個奇特的宏來自哪里提供了一些基本的解釋。

仔細研究表明,SVID也是一個標准, 由此支持。 GNU標准gnu89和gnu99可能涵蓋了盡可能多的東西,因此產生的行為表明uint不包含在C99中,但是對於gcc和clang的默認標准是可以理解的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM