?
Dokumen ini menggunakan Manual laman web PHP Cina Lepaskan
定義的每個宏都<errno.h>
擴展為一個帶有類型int
和唯一正值的整型常量表達式。以下常量由ISO C定義。只要開始'E'
后跟數(shù)字或大寫字母,實現(xiàn)可定義更多。
| 在頭文件<errno.h> |中定義
|:----|
| EDOM | 數(shù)學參數(shù)超出函數(shù)域(宏常量)|
| EILSEQ(C95)| 非法字節(jié)序列(宏常量)|
| ERANGE | 結(jié)果太大(宏常量)|
許多額外的errno常量由POSIX和C ++標準庫定義,并且各個實現(xiàn)可能定義更多,例如errno(3)
在Linux上或intro(2)
BSD和OS X上。
#include <stdio.h>#include <math.h>#include <errno.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));}
可能的輸出:
log(-1.0) = nan Numerical argument out of domain log(0.0) = -inf Numerical result out of range
C11標準(ISO/IEC 9899:2011):
7.5/2錯誤<errno.h>(p:205)
C99標準(ISO/IEC 9899:1999):
7.5/2錯誤<errno.h>(p:186)
C89/C90標準(ISO/IEC 9899:1990):
4.1.3錯誤<errno.h>
錯誤號 | 宏擴展到POSIX兼容的線程局部錯誤號變量(宏變量) |
---|---|
PERROR | 顯示當前錯誤對應(yīng)的字符串到stderr(函數(shù)) |
strerrorstrerror_sstrerrorlen_s(C11)(C11) | 返回給定錯誤代碼(函數(shù))的文本版本 |
| C++ documentation for Error numbers |