Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      Error handling

      From cppreference.com
      <c
       
       
      Error handling
      Error codes
      Error codes
      Assertions
      (C11)(removed in C23)
      Bounds checking
       

      Contents

      [edit]Error numbers

      Defined in header<errno.h>
      macro which expands to POSIX-compatible thread-local error number variable
      (macro variable)[edit]
      macros for standard POSIX-compatible error conditions
      (macro constant)[edit]

      [edit]Assertions

      Defined in header<assert.h>
      aborts the program if the user-specified condition is nottrue. May be disabled for release builds
      (function macro)[edit]
      (C11)(removed in C23)
      issues a compile-time diagnostic if the value of a constant expression is false
      (keyword macro)

      Bounds checking

      The standard library provides bounds-checked versions of some existing functions (gets_s,fopen_s,printf_s,strcpy_s,wcscpy_s,mbstowcs_s,qsort_s,getenv_s, etc). This functionality isoptional and is only available if__STDC_LIB_EXT1__ is defined. The following macros and functions support this functionality.

       
      Defined in header<errno.h>
      Defined in header<stdio.h>
      errno_t
      (C11)
      a typedef for the typeint, used to self-document functions that returnerrno values
      (typedef)
       
      Defined in header<stddef.h>
      Defined in header<stdio.h>
      Defined in header<stdlib.h>
      Defined in header<string.h>
      Defined in header<time.h>
      Defined in header<wchar.h>
      rsize_t
      (C11)
      a typedef for the same type assize_t, used to self-document functions that range-check their parameters at runtime
      (typedef)
       
      Defined in header<stdint.h>
      RSIZE_MAX
      (C11)
      largest acceptable size for bounds-checked functions, expands to either constant or variable which may change at runtime (e.g. as the currently allocated memory size changes)
      (macro variable)
       
      Defined in header<stdlib.h>
      set the error callback for bounds-checked functions
      (function)[edit]
      abort callback for the bounds-checked functions
      (function)[edit]
      ignore callback for the bounds-checked functions
      (function)[edit]

      Note: implementations of bounds-checked functions are available as open-source librariesSafe C andSlibc, and as part of Watcom C. There is also an incompatible set of bounds-checked functions available in Visual Studio.

      (since C11)

      [edit]Notes

      Since C23,static_assert is itself a keyword, which may also be a predefined macro, so<assert.h> no longer provides it.

      [edit]References

      Extended content
      • C23 standard (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 standard (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 standard (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 standard (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 standard (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>

      [edit]See also

      defines the error handling mechanism used by the common mathematical functions
      (macro constant)[edit]
      C++ documentation forError handling
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/error&oldid=180038"

      [8]ページ先頭

      ©2009-2025 Movatter.jp