约 995 字

约 5 分钟

#C 语言标准库函数 set_constraint_handler_s

#define __STDC_WANT_LIB_EXT1__ 1
#include <stdlib.h>

constraint_handler_t set_constraint_handler_s(constraint_handler_t handler);

说明

安装附录 K 接口用于报告运行时约束违反的处理函数。

C11 附录 K 可选接口。需要定义 __STDC_LIB_EXT1__ 的实现,并在包含相关头文件前将 __STDC_WANT_LIB_EXT1__ 定义为 1。

参数

  • handler - 处理函数指针,或表示恢复实现默认处理方式的空指针。

返回值

  • 返回先前安装的处理函数指针。如果此前使用默认处理函数,返回值的表示由实现定义。

#示例

#define __STDC_WANT_LIB_EXT1__ 1
#include <stdlib.h>

int main(void)
{
    constraint_handler_t previous = set_constraint_handler_s(ignore_handler_s);
    (void)set_constraint_handler_s(previous);
    return 0;
}

#相关接口

#参考标准

更新: 2026/11/28

作者: planc

创建: 2026/11/28