Namespaces
Variants

ignore_handler_s

From cppreference.net
< c ‎ | error
헤더 파일에 정의됨 <stdlib.h>
void ignore_handler_s ( const char * restrict msg,

void * restrict ptr,
errno_t error

) ;
(C11 이후)

이 함수는 다른 동작을 수행하지 않고 호출자에게 반환됩니다.

이 함수에 대한 포인터는 아무 작업도 수행하지 않는 런타임 제약 조건 위반 핸들러를 설정하기 위해 set_constraint_handler_s 에 전달될 수 있습니다.

모든 경계 검사 함수와 마찬가지로, ignore_handler_s 함수는 구현체가 __STDC_LIB_EXT1__ 를 정의하고, 사용자가 __STDC_WANT_LIB_EXT1__ 를 정수 상수 1 로 정의한 후에만 <stdlib.h> 를 포함할 때 사용 가능함이 보장됩니다.

목차

매개변수

msg - 오류를 설명하는 문자 문자열에 대한 포인터
ptr - 구현 정의 객체 또는 null 포인터에 대한 포인터. 구현 정의 객체의 예로는 위반을 감지한 함수 이름과 위반이 감지된 라인 번호를 제공하는 객체가 있습니다
error - 호출 함수에 의해 반환될 예정인 오류 (해당 함수가 errno_t를 반환하는 함수 중 하나인 경우)

반환값

(없음)

참고 사항

만약 ignore_handler_s 가 런타임 제약 핸들러로 사용되면, 위반 사항은 경계 검사 함수 호출 결과를 검사하여 감지될 수 있으며, 이는 함수마다 다를 수 있습니다 (0이 아닌 errno_t , 출력 문자열의 첫 번째 바이트에 null 문자가 기록되는 경우 등)

만약 set_constraint_handler_s 가 호출되지 않으면, 기본 핸들러는 구현에 따라 정의됩니다: abort_handler_s , ignore_handler_s , 또는 다른 구현에 따라 정의된 핸들러일 수 있습니다.

예제

#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
#ifdef __STDC_LIB_EXT1__
    char dst[2];
    set_constraint_handler_s(ignore_handler_s);
    int r = strcpy_s(dst, sizeof dst, "Too long!");
    printf("dst = \"%s\", r = %d\n", dst, r);
    set_constraint_handler_s(abort_handler_s);
    r = strcpy_s(dst, sizeof dst, "Too long!");
    printf("dst = \"%s\", r = %d\n", dst, r);
#endif
}

가능한 출력:

dst = "", r = 22
abort_handler_s was called in response to a runtime-constraint violation.
The runtime-constraint violation was caused by the following expression in strcpy_s:
(s1max <= (s2_len=strnlen_s(s2, s1max)) ) (in string_s.c:62)
Note to end users: This program was terminated as a result
of a bug present in the software. Please reach out to your
software's vendor to get more help.
Aborted

참고문헌

  • C11 표준 (ISO/IEC 9899:2011):
  • K.3.6.1.3 ignore_handler_s 함수 (p: 606)

참고 항목

경계 검사 함수를 위한 중단 콜백
(함수)
경계 검사 함수를 위한 오류 콜백 설정
(함수)