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

UINTN_WIDTH宏


概要:
#include <stdint.h>
#define UINTN_WIDTH N

描述:

该宏表示宽度为N的无符号整数类型的宽度,即uintN_t类型的宽度。

如果实现提供了uintN_t类型,实现应定义宏UINTN_WIDTH。该宏应替换为适合在#if预处理指令中使用的常量表达式,其实现定义值等于N。


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

#include <stdint.h>
#include <stdio.h>

int main(void)
{
    printf("UINT8_WIDTH = %d\n", UINT8_WIDTH);
    printf("UINT16_WIDTH = %d\n", UINT16_WIDTH);
    printf("UINT32_WIDTH = %d\n", UINT32_WIDTH);
    printf("UINT64_WIDTH = %d\n", UINT64_WIDTH);

    return 0;
}


可能输出:

UINT8_WIDTH = 8

UINT16_WIDTH = 16

UINT32_WIDTH = 32

UINT64_WIDTH = 64

(注:编译时实现未定义宏UINT8_WIDTH、UINT16_WIDTH、UINT32_WIDTH、UINT64_WIDTH。)


相关内容:
INTN_WIDTH 表示宽度为N的有符号整数类型宽度的宏。


主要参考资料:

1、ISO/IEC 9899:2024