errno
提供: cppreference.com
|
|
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
| Defined in header <cerrno>
|
||
| #define errno /*implementation-defined*/ |
||
errnoタイプ(C++11以前)のstatic(C++11およびそれ以降)/スレッドlocalint変更可能な左辺値に展開されるプリプロセッサマクロです。いくつかの標準ライブラリ関数はerrnoに正の整数を書き込むことで、エラーを示します。通常、errnoの値は大文字または数字が続く文字列の<cerrno>で始まるマクロ定数としてEに記載されているエラー·コード、、のいずれかに設定されて.Original:
errno is a preprocessor macro that expands to a static(C++11以前) / thread-local(C++11およびそれ以降) modifiable lvalue of type int. Several standard library functions indicate errors by writing positive integers to errno. Typically, the value of errno is set to one of the error codes, listed in <cerrno> as macro constants that begin with the letter E, followed by uppercase letters or digits.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
errnoの値は、プログラムの起動時に0で、ライブラリ関数はエラーが発生したかどうかerrnoに正の整数を書き込みを許可されていますが、ライブラリ関数は0でerrnoを格納することはありません.Original:
The value of
errno is 0 at program startup, and although library functions are allowed to write positive integers to errno whether or not an error occurred, library functions never store 0 in errno.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例
このコードを実行します
#include <iostream> #include <cmath> #include <cerrno> #include <cstring> int main() { double not_a_number = std::log(-1.0); if (errno == EDOM) { std::cout << "log(-1) failed: " << std::strerror(errno) << '\n'; } }
出力:
log(-1) failed: Numerical argument out of domain
[編集] 参照
| 標準のPOSIX互換のエラー条件のためのマクロ Original: macros for standard POSIX-compatible error conditions The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (マクロ定数) | |
| stderrに現在のエラーの対応する文字列が表示されます Original: displays a character string corresponding of the current error to stderr The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数) | |
| 指定したエラーコードのテキストバージョンを返します Original: returns a text version of a given error code The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数) | |

