.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de) .\" .\" %%%LICENSE_START(VERBATIM) .\" 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. .\" %%%LICENSE_END .\" .\" Modified Sat Jul 24 21:42:42 1993 by Rik Faith .\" Modified Tue Oct 22 23:44:11 1996 by Eric S. Raymond .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1996 Kentaro OGAWA .\" all rights reserved. .\" Translated Sun, 14 Jul 1996 01:33:26 +0900 .\" by Kentaro OGAWA .\" Updated Fri 6 Oct JST 2000 by Kentaro Shirakata .\" Updated Thu 19 Sep JST 2002 by Kentaro Shirakata .\" .TH ASSERT 3 2013\-09\-26 GNU "Linux Programmer's Manual" .SH 名前 assert \- 診断が偽の時にプログラムを中止する .SH 書式 .nf \fB#include \fP .sp \fBvoid assert(scalar \fP\fIexpression\fP\fB);\fP .fi .SH 説明 \fI\fP が最後にインクルードされた時点で、 \fBNDEBUG\fP マクロが定義されていた場合、 \fBassert\fP() マクロは何のコードも生成せず、従って全く何もしない。 さもなければ、 \fBassert\fP(3) マクロは \fIexpression\fP が偽の時(すなわち、比較の結果が0と等しい時)に 標準エラー出力にエラーメッセージを表示し、さらに \fBabort\fP() を呼び出すことによって、プログラムを終了させる。 .LP このマクロの目的は、プログラマーがプログラムのバグを発見する手助けをすることである。"assertion failed in file foo.c, function do_bar(), line 1287" というメッセージはユーザーには何の助けにもならない。 .SH 返り値 値は返されない。 .SH 準拠 .\" See Defect Report 107 for more details. POSIX.1\-2001, C89, C99. C89 では \fBexpression\fP は \fIint\fP 型であることが必要とされ、そうでない場合の動作は未定義とされていた。 しかし C99 ではどのようなスカラ値でもよいことになった。 .SH バグ \fBassert\fP() は、マクロとして実装されている。すなわち、 試されている式が副作用を持っている場合には、 マクロ \fBNDEBUG\fP が定義されているかどうかに依存して、プログラムの振舞いは異なるだろう。 これによって、バグ出しするときには消えてしまう ハイゼンバグ(Heisenbugs)を生み出すだろう。 .SH 関連項目 \fBabort\fP(3), \fBassert_perror\fP(3), \fBexit\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。