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

SIG_ATOMIC_MAX宏


概要:

#define SIG_ATOMIC_MAX value //value值由实现定义。


描述:

该宏表示sig_atomic_t类型的最大值。

如果sig_atomic_t定义为有符号整数类型,SIG_ATOMIC_MAX值应不小于127,具体值由实现定义;如果sig_atomic_t定义为无符号整数类型,SIG_ATOMIC_MAX值应不小于255,具体值由实现定义。

具体实现中,该宏应替换为适合在#if预处理指令中使用的常量表达式,并且该表达式应具有与相应对象类型(整数提升后)相同的类型。


范例:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
/*宏SIG_ATOMIC_MAX范例*/

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

int main(void)
{
    if((sig_atomic_t)(-1)<0)
    {
        puts("sig_atomic_t is defined as a signed integer type.");
        printf("SIG_ATOMIC_MAX = %d\n", SIG_ATOMIC_MAX);
    }
    else
    {
        puts("sig_atomic_t is defined as an unsigned integer type.");
        printf("SIG_ATOMIC_MAX = %u\n", SIG_ATOMIC_MAX);
    }

    return 0;
}


输出:

sig_atomic_t is defined as a signed integer type.

SIG_ATOMIC_MAX = 2147483647

如果sig_atomic_t为有符号整数类型,(sig_atomic_t)(-1)将小于0;如果sig_atomic_t为无符号整数类型,(sig_atomic_t)(-1)将大于0,具体解释请参阅整数的存储


相关内容:
SIG_ATOMIC_MIN 表示sig_atomic_t类型最小值的宏。