?
本文檔使用 PHP中文網(wǎng)手冊(cè) 發(fā)布
定義的每個(gè)宏都<errno.h>
擴(kuò)展為一個(gè)帶有類型int
和唯一正值的整型常量表達(dá)式。以下常量由ISO C定義。只要開始'E'
后跟數(shù)字或大寫字母,實(shí)現(xiàn)可定義更多。
| 在頭文件<errno.h> |中定義
|:----|
| EDOM | 數(shù)學(xué)參數(shù)超出函數(shù)域(宏常量)|
| EILSEQ(C95)| 非法字節(jié)序列(宏常量)|
| ERANGE | 結(jié)果太大(宏常量)|
許多額外的errno常量由POSIX和C ++標(biāo)準(zhǔn)庫(kù)定義,并且各個(gè)實(shí)現(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標(biāo)準(zhǔn)(ISO/IEC 9899:2011):
7.5/2錯(cuò)誤<errno.h>(p:205)
C99標(biāo)準(zhǔn)(ISO/IEC 9899:1999):
7.5/2錯(cuò)誤<errno.h>(p:186)
C89/C90標(biāo)準(zhǔn)(ISO/IEC 9899:1990):
4.1.3錯(cuò)誤<errno.h>
錯(cuò)誤號(hào) | 宏擴(kuò)展到POSIX兼容的線程局部錯(cuò)誤號(hào)變量(宏變量) |
---|---|
PERROR | 顯示當(dāng)前錯(cuò)誤對(duì)應(yīng)的字符串到stderr(函數(shù)) |
strerrorstrerror_sstrerrorlen_s(C11)(C11) | 返回給定錯(cuò)誤代碼(函數(shù))的文本版本 |
| C++ documentation for Error numbers |