abort_handler_s
|
헤더 파일에 정의됨
<stdlib.h>
|
||
|
void
abort_handler_s
(
const
char
*
restrict
msg,
void
*
restrict
ptr,
|
(C11 이후) | |
구현에서 정의된 메시지를
stderr
에 기록합니다. 이 메시지는 반드시
msg
가 가리키는 문자열을 포함해야 하며,
abort()
를 호출합니다.
이 함수에 대한 포인터는 런타임 제약 조건 위반 핸들러를 설정하기 위해 set_constraint_handler_s 에 전달될 수 있습니다.
-
모든 경계 검사 함수와 마찬가지로,
abort_handler_s는 구현체가 __STDC_LIB_EXT1__ 를 정의하고 사용자가 __STDC_WANT_LIB_EXT1__ 를 정수 상수 1 로 정의한 경우에만 사용 가능함이 보장됩니다<stdlib.h>를 포함하기 전에.
목차 |
매개변수
| msg | - | 표준 오류 스트림에 기록된 메시지에 대한 포인터 |
| ptr | - | 구현 정의 객체 또는 널 포인터에 대한 포인터. 구현 정의 객체의 예로는 위반을 감지한 함수 이름과 위반이 감지된 라인 번호를 제공하는 객체가 있습니다 |
| error | - | errno_t 타입의 양수 값 |
반환값
없음; 이 함수는 호출자에게 반환되지 않음
참고 사항
만약
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.2 abort_handler_s 함수 (p: 605)
참고 항목
|
(C11)
|
경계 검사 함수용 무시 콜백
(함수) |
|
(C11)
|
경계 검사 함수용 오류 콜백 설정
(함수) |