Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      Error numbers

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

      Each of the macros defined in<errno.h> expands to an integer constant expression with typeint and with a unique positive value. The following constants are defined by ISO C. The implementation may define more, as long as they begin with'E' followed by digits or uppercase letters.

      Defined in header<errno.h>
      EDOM
      Mathematics argument out of domain of function
      (macro constant)
      EILSEQ
      (C95)
      Illegal byte sequence
      (macro constant)
      ERANGE
      Result too large
      (macro constant)

      Contents

      [edit]Notes

      Many additional errno constants aredefined by POSIX and by theC++ standard library, and individual implementations may define even more, e.g.errno(3) on Linux orintro(2) on BSD and OS X.

      [edit]Example

      Run this code
      #include <errno.h>#include <math.h>#include <stdio.h>#include <string.h> int main(void){errno=0;printf("log(-1.0) = %f\n",log(-1.0));printf("%s\n\n",strerror(errno)); errno=0;printf("log(0.0)  = %f\n",log(0.0));printf("%s\n",strerror(errno));}

      Possible output:

      log(-1.0) = nanNumerical argument out of domain log(0.0)  = -infNumerical result out of range

      [edit]References

      • C23 standard (ISO/IEC 9899:2024):
      • 7.5/2 Errors <errno.h> (p: TBD)
      • C17 standard (ISO/IEC 9899:2018):
      • 7.5/2 Errors <errno.h> (p: TBD)
      • C11 standard (ISO/IEC 9899:2011):
      • 7.5/2 Errors <errno.h> (p: 205)
      • C99 standard (ISO/IEC 9899:1999):
      • 7.5/2 Errors <errno.h> (p: 186)
      • C89/C90 standard (ISO/IEC 9899:1990):
      • 4.1.3 Errors <errno.h>

      [edit]See also

      macro which expands to POSIX-compatible thread-local error number variable
      (macro variable)[edit]
      displays a character string corresponding of the current error tostderr
      (function)[edit]
      returns a text version of a given error code
      (function)[edit]
      C++ documentation forError numbers
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/error/errno_macros&oldid=180046"

      [8]ページ先頭

      ©2009-2025 Movatter.jp