CHAR_BIT==16這段代碼是什么意思?它無法編譯,我無法弄清楚原因以及 puts 中的內容會編譯嗎?
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
static_assert(CHAR_BIT==16,"16 bit falsely assumed");
int main()
{
puts("hello world this");
return 0;
}
uj5u.com熱心網友回復:
CHAR_BIT是一個宏定義在limits.h. 它提到了 a 中的位數char。大多數系統使用 8 位,但也有更少(7 位)或更多的架構。
在您的代碼中,斷言正在檢查,如果系統使用 16 位 a char,那么只有代碼會編譯。
注意:根據您的編譯器版本和支持,您可能需要_Static_assert改用。
uj5u.com熱心網友回復:
CHAR_BIT中定義<limits.h>。您需要包含它才能編譯代碼。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/441818.html
上一篇:檢查檔案是否在C中打開
