.\" Copyright (C) 2002 Andries Brouwer .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" This replaces an earlier man page written by Walter Harms .\" . .\" .\" Japanese Version Copyright (c) 2003 Akihiro MOTOKI .\" all rights reserved. .\" Translated Tue Jul 8 05:09:37 JST 2003 .\" by Akihiro MOTOKI .\" .TH ASSERT_PERROR 3 2002-08-25 "GNU" "Linux Programmer's Manual" .\"O .SH NAME .\"O assert_perror \- test errnum and abort .SH 名前 assert_perror \- test errnum and abort .\"O .SH SYNOPSIS .SH 書式 .nf .\"O .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" .BR "#define _GNU_SOURCE" " /* feature_test_macros(7) 参照 */" .B #include .sp .BI "void assert_perror(int " errnum ); .fi .\"O .SH DESCRIPTION .SH 説明 .\"O If the macro .\"O .B NDEBUG .\"O was defined at the moment .\"O .I .\"O was last included, the macro .\"O .BR assert_perror () .\"O generates no code, and hence does nothing at all. 最後に .I がインクルードされた時にマクロ .B NDEBUG が定義されていた場合、マクロ .BR assert_perror () は何のコードも生成せず、したがって全く何もしない。 .\"O Otherwise, the macro .\"O .BR assert_perror () .\"O prints an error message to standard error and terminates the program .\"O by calling .\"O .BR abort (3) .\"O if .\"O .I errnum .\"O is nonzero. .\"O The message contains the filename, function name and .\"O line number of the macro call, and the output of .\"O .IR strerror(errnum) . そうでない場合、マクロ .BR assert_perror () は標準エラーにエラー・メッセージを表示し、 .I errnum が 0 でない場合には .BR abort (3) を呼び出してプログラムを終了させる。 メッセージには、ファイル名、マクロ呼び出しがあった関数名と行番号、 .I strerror(errnum) の出力が含まれる。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O No value is returned. 返り値はない。 .\"O .SH "CONFORMING TO" .SH 準拠 .\"O This is a GNU extension. これは GNU による拡張である。 .\"O .SH BUGS .SH バグ .\"O The purpose of the assert macros is to help the programmer find bugs in .\"O his program, things that cannot happen unless there was a coding mistake. .\"O However, with system or library calls the situation is rather different, .\"O and error returns can happen, and will happen, and should be tested for. .\"O Not by an assert, where the test goes away when .\"O .B NDEBUG .\"O is defined, .\"O but by proper error handling code. .\"O Never use this macro. assert マクロの目的は、プログラマがプログラム中のバグを探す手助けをすること であり、コーディング間違いがない場合には何が起こることはありえない。 しかしながら、システムコールやライブラリコールの場合、状況がかなり違っていて、 エラーが返されることがありえるし、実際あるだろう。そしてそのような状況でも テストされるべきである。この場合には、 .B NDEBUG を定義することで無効にできる assert ではなく、適切なエラー処理コードで対処すべきである。 このマクロは決して使わないこと。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR abort (3), .BR assert (3), .BR exit (3), .BR strerror (3)