.\" Copyright (C) 2002 Andries Brouwer .\" .\" %%%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 .\" .\" This replaces an earlier man page written by Walter Harms .\" . .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" 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 2017\-09\-15 GNU "Linux Programmer's Manual" .SH 名前 assert_perror \- test errnum and abort .SH 書式 .nf \fB#define _GNU_SOURCE\fP /* feature_test_macros(7) 参照 */ \fB#include \fP .PP \fBvoid assert_perror(int \fP\fIerrnum\fP\fB);\fP .fi .SH 説明 最後に \fI\fP がインクルードされた時にマクロ \fBNDEBUG\fP が定義されていた場合、マクロ \fBassert_perror\fP() は何のコードも生成せず、したがって全く何もしない。 そうでない場合、マクロ \fBassert_perror\fP() は標準エラーにエラーメッセージを表示し、 \fIerrnum\fP が 0 でない場合には \fBabort\fP(3) を呼び出してプログラムを終了させる。 メッセージには、ファイル名、マクロ呼び出しがあった関数名と行番号、 \fIstrerror(errnum)\fP の出力が含まれる。 .SH 返り値 値は返されない。 .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lb lb lb l l l. インターフェース 属性 値 T{ \fBassert_perror\fP() T} Thread safety MT\-Safe .TE .sp 1 .SH 準拠 これは GNU による拡張である。 .SH バグ assert マクロの目的は、プログラマがプログラム中のバグを探す手助けをすることであり、コーディング間違いがない場合には何が起こることはありえない。 しかしながら、システムコールやライブラリコールの場合、状況がかなり違っていて、 エラーが返されることがありえるし、実際あるだろう。そしてそのような状況でも テストされるべきである。この場合には、 \fBNDEBUG\fP を定義することで無効にできる assert ではなく、適切なエラー処理コードで対処すべきである。 このマクロは決して使わないこと。 .SH 関連項目 \fBabort\fP(3), \fBassert\fP(3), \fBexit\fP(3), \fBstrerror\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。