当前位置: C语言 -- 附录 -- ignore_handler_s

ignore_handler_s函数


概要:
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdlib.h>
void ignore_handler_s(
      const char * restrict msg,
      void * restrict ptr,
      errno_t error);

描述:

指向ignore_handler_s函数的指针可用作set_constraint_handler_s函数的参数。

该函数返回给调用者。如果运行约束处理程序设置为ignore_handler_s函数,任何发生运行约束冲突的库函数都将返回给它的调用者。调用者根据库函数规范确定是否发生了运行约束冲突(通常库函数返回一个errno_t类型的非0值。)。


参数:
const char * restrict msg

指向描述运行约束冲突字符串的指针。

void * restrict ptr

空指针或者指向实现定义对象的指针。

errno_t error

如果调用运行约束处理程序的安全函数的返回类型是errno_t,参数error是安全函数的返回值;否则参数error为传递的errno_t类型的正值。


返回值:

无。


范例:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
/*安全函数ignore_handler_s范例*/

#define __STDC_WANT_LIB_EXT1__ 1
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    set_constraint_handler_s(ignore_handler_s);

    FILE *pFile;
    char *mode = NULL;
    fopen_s(&pFile, "gch.txt", mode);  //运行约束:mode不能为空指针。
    fclose(pFile);

    return 0;
}


结果:

注:测试时Visual Studio软件还未支持ignore_handler_s函数,以上例子仅供参考。


相关内容:
set_constraint_handler_s 设置运行约束处理程序的安全函数。
abort_handler_s 发生运行约束冲突时终止调用安全函数的安全函数。