1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
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.
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.
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
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Modified Sat Jul 24 21:42:42 1993 by Rik Faith <faith@cs.unc.edu>
24 .\" Modified Tue Oct 22 23:44:11 1996 by Eric S. Raymond <esr@thyrsus.com>
26 .\" Japanese Version Copyright (c) 1996 Kentaro OGAWA
27 .\" all rights reserved.
28 .\" Translated Sun, 14 Jul 1996 01:33:26 +0900
29 .\" by Kentaro OGAWA <k_ogawa@oyna.cc.muroran-it.ac.jp>
30 .\" Updated Fri 6 Oct JST 2000 by Kentaro Shirakata <argrath@ub32.org>
31 .\" Updated Thu 19 Sep JST 2002 by Kentaro Shirakata <argrath@ub32.org>
33 .TH ASSERT 3 2002-08-25 "GNU" "Linux Programmer's Manual"
35 assert \- ¿ÇÃǤ¬µ¶¤Î»þ¤Ë¥×¥í¥°¥é¥à¤òÃæ»ß¤¹¤ë
38 .B #include <assert.h>
40 .BI "void assert(scalar " expression );
45 .\"O was defined at the moment
47 .\"O was last included, the macro
49 .\"O generates no code, and hence does nothing at all.
51 ¤¬ºÇ¸å¤Ë¥¤¥ó¥¯¥ë¡¼¥É¤µ¤ì¤¿»þÅÀ¤Ç¡¢
53 ¥Þ¥¯¥í¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤¿¾ì¹ç¡¢
55 ¥Þ¥¯¥í¤Ï²¿¤Î¥³¡¼¥É¤âÀ¸À®¤»¤º¡¢½¾¤Ã¤ÆÁ´¤¯²¿¤â¤·¤Ê¤¤¡£
56 .\"O Otherwise, the macro
58 .\"O prints an error message to standard error and terminates the program
63 .\"O is false (i.e., compares equal to zero).
68 ¤¬µ¶¤Î»þ(¤¹¤Ê¤ï¤Á¡¢Èæ³Ó¤Î·ë²Ì¤¬0¤ÈÅù¤·¤¤»þ)¤Ë
69 ɸ½à¥¨¥é¡¼½ÐÎϤ˥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤·¡¢¤µ¤é¤Ë
71 ¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤Ë¤è¤Ã¤Æ¡¢¥×¥í¥°¥é¥à¤ò½ªÎ»¤µ¤»¤ë¡£
73 .\"O The purpose of this macro is to help the programmer find bugs in
75 .\"O The message "assertion failed in file foo.c, function
76 .\"O do_bar(), line 1287" is of no help at all to a user.
77 ¤³¤Î¥Þ¥¯¥í¤ÎÌÜŪ¤Ï¡¢¥×¥í¥°¥é¥Þ¡¼¤¬¥×¥í¥°¥é¥à¤Î¥Ð¥°¤òȯ¸«¤¹¤ë¼ê½õ¤±¤ò
78 ¤¹¤ë¤³¤È¤Ç¤¢¤ë¡£"assertion failed in file foo.c, function do_bar(), line 1287"
79 ¤È¤¤¤¦¥á¥Ã¥»¡¼¥¸¤Ï¥æ¡¼¥¶¡¼¤Ë¤Ï²¿¤Î½õ¤±¤Ë¤â¤Ê¤é¤Ê¤¤¡£
83 .\"O POSIX.1-2001, C89, C99.
86 .\"O is required to be of type
88 .\"O and undefined behavior results if it is not, but in C99
89 .\"O it may have any scalar type.
90 POSIX.1-2001, C89, C99.
95 ·¿¤Ç¤¢¤ë¤³¤È¤¬É¬ÍפȤµ¤ì¡¢¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤ÎÆ°ºî¤Ï̤ÄêµÁ¤È¤µ¤ì¤Æ¤¤¤¿¡£
96 ¤·¤«¤· C99 ¤Ç¤Ï¤É¤Î¤è¤¦¤Ê¥¹¥«¥éÃͤǤâ¤è¤¤¤³¤È¤Ë¤Ê¤Ã¤¿¡£
97 .\"O .\" See Defect Report 107 for more details.
98 .\" ¾ÜºÙ¤ÏÉÔ¶ñ¹çÊó¹ð 107 ¤ò»²¾È¤Î¤³¤È¡£
101 .\"O is implemented as a macro; if the expression tested has side-effects,
102 .\"O program behavior will be different depending on whether
105 .\"O This may create Heisenbugs which go away when debugging
108 ¤Ï¡¢¥Þ¥¯¥í¤È¤·¤Æ¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¡£¤¹¤Ê¤ï¤Á¡¢
109 »î¤µ¤ì¤Æ¤¤¤ë¼°¤¬ÉûºîÍѤò»ý¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢
112 ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤Ë°Í¸¤·¤Æ¡¢¥×¥í¥°¥é¥à¤Î¿¶Éñ¤¤¤Ï°Û¤Ê¤ë¤À¤í¤¦¡£
113 ¤³¤ì¤Ë¤è¤Ã¤Æ¡¢¥Ð¥°½Ð¤·¤¹¤ë¤È¤¤Ë¤Ï¾Ã¤¨¤Æ¤·¤Þ¤¦
114 ¥Ï¥¤¥¼¥ó¥Ð¥°(Heisenbugs)¤òÀ¸¤ß½Ð¤¹¤À¤í¤¦¡£
117 .BR assert_perror (3),