OSDN Git Service

14d3cf3a9a2f35505b51ac38e215a6d4ab83fd12
[linuxjm/LDP_man-pages.git] / draft / man3 / assert_perror.3
1 .\" Copyright (C) 2002 Andries Brouwer <aeb@cwi.nl>
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" This replaces an earlier man page written by Walter Harms
24 .\" <walter.harms@informatik.uni-oldenburg.de>.
25 .\"
26 .\" Japanese Version Copyright (c) 2003  Akihiro MOTOKI
27 .\"         all rights reserved.
28 .\" Translated Tue Jul  8 05:09:37 JST 2003
29 .\"         by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
30 .\"
31 .TH ASSERT_PERROR 3  2002-08-25 "GNU" "Linux Programmer's Manual"
32 .\"O .SH NAME
33 .\"O assert_perror \- test errnum and abort
34 .SH 名前
35 assert_perror \- test errnum and abort
36 .\"O .SH SYNOPSIS
37 .SH 書式
38 .nf
39 .\"O .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
40 .BR "#define _GNU_SOURCE" "         /* feature_test_macros(7) 参照 */"
41 .B #include <assert.h>
42 .sp
43 .BI "void assert_perror(int " errnum );
44 .fi
45 .\"O .SH DESCRIPTION
46 .SH 説明
47 .\"O If the macro
48 .\"O .B NDEBUG
49 .\"O was defined at the moment
50 .\"O .I <assert.h>
51 .\"O was last included, the macro
52 .\"O .BR assert_perror ()
53 .\"O generates no code, and hence does nothing at all.
54 最後に
55 .I <assert.h>
56 がインクルードされた時にマクロ
57 .B NDEBUG
58 が定義されていた場合、マクロ
59 .BR assert_perror ()
60 は何のコードも生成せず、したがって全く何もしない。
61 .\"O Otherwise, the macro
62 .\"O .BR assert_perror ()
63 .\"O prints an error message to standard error and terminates the program
64 .\"O by calling
65 .\"O .BR abort (3)
66 .\"O if
67 .\"O .I errnum
68 .\"O is nonzero.
69 .\"O The message contains the filename, function name and
70 .\"O line number of the macro call, and the output of
71 .\"O .IR strerror(errnum) .
72 そうでない場合、マクロ
73 .BR assert_perror ()
74 は標準エラーにエラー・メッセージを表示し、
75 .I errnum
76 が 0 でない場合には
77 .BR abort (3)
78 を呼び出してプログラムを終了させる。
79 メッセージには、ファイル名、マクロ呼び出しがあった関数名と行番号、
80 .I strerror(errnum)
81 の出力が含まれる。
82 .\"O .SH "RETURN VALUE"
83 .SH 返り値
84 .\"O No value is returned.
85 返り値はない。
86 .\"O .SH "CONFORMING TO"
87 .SH 準拠
88 .\"O This is a GNU extension.
89 これは GNU による拡張である。
90 .\"O .SH BUGS
91 .SH バグ
92 .\"O The purpose of the assert macros is to help the programmer find bugs in
93 .\"O his program, things that cannot happen unless there was a coding mistake.
94 .\"O However, with system or library calls the situation is rather different,
95 .\"O and error returns can happen, and will happen, and should be tested for.
96 .\"O Not by an assert, where the test goes away when
97 .\"O .B NDEBUG
98 .\"O is defined,
99 .\"O but by proper error handling code.
100 .\"O Never use this macro.
101 assert マクロの目的は、プログラマがプログラム中のバグを探す手助けをすること
102 であり、コーディング間違いがない場合には何が起こることはありえない。
103 しかしながら、システムコールやライブラリコールの場合、状況がかなり違っていて、
104 エラーが返されることがありえるし、実際あるだろう。そしてそのような状況でも
105 テストされるべきである。この場合には、
106 .B NDEBUG
107 を定義することで無効にできる
108 assert ではなく、適切なエラー処理コードで対処すべきである。
109 このマクロは決して使わないこと。
110 .\"O .SH "SEE ALSO"
111 .SH 関連項目
112 .BR abort (3),
113 .BR assert (3),
114 .BR exit (3),
115 .BR strerror (3)