Namespaces
Variants

Error handling

From cppreference.net
< c

목차

오류 번호

헤더 파일에 정의됨 <errno.h>
POSIX 호환 스레드-로컬 에러 번호 변수로 확장되는 매크로
(매크로 변수)
표준 POSIX 호환 에러 조건을 위한 매크로들
(매크로 상수)

어서션

헤더 파일에 정의됨 <assert.h>
사용자 지정 조건이 true 가 아닐 경우 프로그램을 중단합니다. 릴리스 빌드에서는 비활성화될 수 있음
(함수 매크로)
(C11) (C23에서 제거됨)
상수 표현식의 값이 false일 경우 컴파일 시간 진단을 발생시킵니다
(키워드 매크로)

경계 검사

표준 라이브러리는 일부 기존 함수의 경계 검사 버전을 제공합니다 ( gets_s , fopen_s , printf_s , strcpy_s , wcscpy_s , mbstowcs_s , qsort_s , getenv_s , 등). 이 기능은 선택적 이며 __STDC_LIB_EXT1__ 이 정의된 경우에만 사용할 수 있습니다. 다음 매크로와 함수들은 이 기능을 지원합니다.

헤더 파일 정의 <errno.h>
헤더 파일 정의 <stdio.h>
errno_t
(C11)
int 타입에 대한 typedef, errno 값을 반환하는 함수를 자체 문서화하는 데 사용됨
(typedef)
헤더 파일 정의 <stddef.h>
헤더 파일 정의 <stdio.h>
헤더 파일 정의 <stdlib.h>
헤더 파일 정의 <string.h>
헤더 파일 정의 <time.h>
헤더 파일 정의 <wchar.h>
rsize_t
(C11)
size_t 와 동일한 타입에 대한 typedef, 런타임에 매개변수 범위 검사를 수행하는 함수를 자체 문서화하는 데 사용됨
(typedef)
헤더 파일 정의 <stdint.h>
RSIZE_MAX
(C11)
경계 검사 함수에서 허용되는 최대 크기, 상수 또는 런타임에 변경될 수 있는 변수로 확장됨 (예: 현재 할당된 메모리 크기가 변경됨에 따라)
(매크로 변수)
헤더 파일 정의 <stdlib.h>
경계 검사 함수를 위한 오류 콜백 설정
(함수)
경계 검사 함수를 위한 중단 콜백
(함수)
경계 검사 함수를 위한 무시 콜백
(함수)

참고: 경계 검사 함수의 구현은 오픈소스 라이브러리인 Safe C Slibc , 그리고 Watcom C의 일부로 사용할 수 있습니다. 또한 Visual Studio에서는 호환되지 않는 경계 검사 함수 집합도 사용할 수 있습니다.

(C11 이후)

참고 사항

C23 이후로, static_assert 는 그 자체로 키워드이며, 사전 정의된 매크로일 수도 있으므로 <assert.h> 는 더 이상 이를 제공하지 않습니다.

참고문헌

확장 콘텐츠
  • C23 표준 (ISO/IEC 9899:2024):
  • 7.2 Diagnostics <assert.h> (p: TBD)
  • 7.5 Errors <errno.h> (p: TBD)
  • 7.19 Common definitions <stddef.h> (p: TBD)
  • 7.20 Integer types <stdint.h> (p: TBD)
  • 7.21 Input/output <stdio.h> (p: TBD)
  • 7.22 General utilities <stdlib.h> (p: TBD)
  • K.3.1.3 Use of errno (p: TBD)
  • K.3.2/2 errno_t (p: TBD)
  • K.3.3/2 rsize_t (p: TBD)
  • K.3.4/2 RSIZE_MAX (p: TBD)
  • 7.31.3 Errors <errno.h> (p: TBD)
  • 7.31.10 Integer types <stdint.h> (p: TBD)
  • 7.31.11 Input/output <stdio.h> (p: TBD)
  • 7.31.12 General utilities <stdlib.h> (p: TBD)
  • C17 표준 (ISO/IEC 9899:2018):
  • 7.2 Diagnostics <assert.h> (p: TBD)
  • 7.5 Errors <errno.h> (p: TBD)
  • 7.19 Common definitions <stddef.h> (p: TBD)
  • 7.20 Integer types <stdint.h> (p: TBD)
  • 7.21 Input/output <stdio.h> (p: TBD)
  • 7.22 General utilities <stdlib.h> (p: TBD)
  • K.3.1.3 Use of errno (p: TBD)
  • K.3.2/2 errno_t (p: TBD)
  • K.3.3/2 rsize_t (p: TBD)
  • K.3.4/2 RSIZE_MAX (p: TBD)
  • 7.31.3 Errors <errno.h> (p: TBD)
  • 7.31.10 Integer types <stdint.h> (p: TBD)
  • 7.31.11 Input/output <stdio.h> (p: TBD)
  • 7.31.12 General utilities <stdlib.h> (p: TBD)
  • C11 표준 (ISO/IEC 9899:2011):
  • 7.2 Diagnostics <assert.h> (p: 186-187)
  • 7.5 Errors <errno.h> (p: 205)
  • 7.19 Common definitions <stddef.h> (p: 288)
  • 7.20 Integer types <stdint.h> (p: 289-295)
  • 7.21 Input/output <stdio.h> (p: 296-339)
  • 7.22 General utilities <stdlib.h> (p: 340-360)
  • K.3.1.3 Use of errno (p: 584)
  • K.3.2/2 errno_t (p: 585)
  • K.3.3/2 rsize_t (p: 585)
  • K.3.4/2 RSIZE_MAX (p: 585)
  • 7.31.3 Errors <errno.h> (p: 455)
  • 7.31.10 Integer types <stdint.h> (p: 456)
  • 7.31.11 Input/output <stdio.h> (p: 456)
  • 7.31.12 General utilities <stdlib.h> (p: 456)
  • C99 표준 (ISO/IEC 9899:1999):
  • 7.2 Diagnostics <assert.h> (p: 169)
  • 7.5 Errors <errno.h> (p: 186)
  • 7.26.3 Errors <errno.h> (p: 401)
  • 7.26.8 Integer types <stdint.h> (p: 401)
  • 7.26.9 Input/output <stdio.h> (p: 402)
  • 7.26.10 General utilities <stdlib.h> (p: 402)
  • C89/C90 표준 (ISO/IEC 9899:1990):
  • 4.2 DIAGNOSTICS <assert.h>
  • 4.1.3 Errors <errno.h>
  • 4.13.1 Errors <errno.h>
  • 4.13.6 Input/output <stdio.h>
  • 4.13.7 General utilities <stdlib.h>

참고 항목

공통 수학 함수들이 사용하는 오류 처리 메커니즘을 정의함
(매크로 상수)
C++ documentation for Error handling