当前位置: C语言 -- 标准库 -- <limits.h> -- UCHAR_WIDTH

UCHAR_WIDTH宏


概要:
#include <limits.h>
#define UCHAR_WIDTH value	//value值由实现定义。

描述:

该宏表示unsigned char类型对象的宽度。

对于无符号整数类型,值位的数量(number of value bits)是无符号整数类型的宽度;对于有符号整数类型,值位和符号位(sign bit)的数量是有符号整数类型的宽度。

宏UCHAR_WIDTH值应不小于8,具体值由实现定义。

宏UCHAR_WIDTH应与宏CHAR_BIT、CHAR_WIDTH、SCHAR_WIDTH具有相同值。


范例:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
/*宏UCHAR_WIDTH范例*/

#include <limits.h>
#include <stdio.h>

int main(void)
{
  #ifdef UCHAR_WIDTH
    printf("UCHAR_WIDTH = %d", UCHAR_WIDTH);
  #else
    puts("The implementation does not define macro UCHAR_WIDTH.");
  #endif
  
  return 0;
}


输出:

The implementation does not define macro UCHAR_WIDTH.


相关内容:
CHAR_BIT 表示非位字段最小对象位数的宏。
CHAR_WIDTH 表示char类型对象宽度的宏。
SCHAR_WIDTH 表示signed char类型对象宽度的宏。


主要参考资料:

1、ISO/IEC 9899:2024