986:
964:
160:
823:
1049:
685:
1030:
1007:
940:
917:
886:
863:
835:
197:
153:
451:
296:
546:
and a string literal; if the expression fails, the string literal is returned, otherwise, the macro has no effect. In
146:
72:
42:
574:
554:
62:
797:
793:
188:
67:
52:
550:, this assertion failure message was made optional, and the subsequent message is omitted if not specified.
237:
macro implements runtime assertion. If the expression within it is false, the macro will print a message to
980:
958:
87:
972:
950:
279:, although any expression that can be implicitly cast to a signed integer may be used. In C99, the
57:
286:
181:
22:
681:
1026:
1003:
999:
936:
932:
913:
882:
878:
859:
831:
543:
395:
Upon compiling the program and running it, a message similar to the following will be output:
245:
82:
77:
47:
901:
325:
905:
855:
845:
Ballman, Aaron; Grammatech (July 6, 2018). Harmonizing static_assert with C++ (Report).
468:
276:
185:
658:
253:. The message includes the source filename and the source line number from the macros
1043:
464:
533:
321:
37:
177:
536:
rather than at runtime. The original implementation used template hacks. The
728:
726:
641:
639:
250:
132:
123:
896:
Gustedt, Jens (February 15, 2022). Revise spelling of keywords (Report).
547:
517:
438:, thus resulting in the macro not evaluating the expression. The use of
114:
705:
586:
239:
204:
570:
208:
1022:
542:
macro takes in a constant expression that can be converted into a
265:, the name of the function the assert statement is included as (
400:
program: source.c:5: main: Assertion 'pointer' failed.
269:) and the expression itself. In ANSI C, the expression in the
262:
852:
Testing Object-oriented
Systems: Models, Patterns, and Tools
444:
may affect the overall behavior of a program if one or more
414:
macro changes depending on the definition of another macro,
299:
is not null and to ensure that an array index is in-bounds.
732:
645:
593:
for platforms that do not use C11 and does not require
471:
can be used to add it to the printed expression, as in
590:
585:and the string literal argument was made optional.
582:
578:
566:
562:
558:
537:
529:
525:
521:
513:
472:
458:
445:
439:
433:
427:
421:
415:
409:
315:
309:
303:
290:
280:
270:
266:
258:
254:
232:
212:
191:
780:
223:are available; both are functionally equivalent.
630:
828:Rationale for the ANSI C Programming Language
154:
8:
975:(January 2012). ISO/IEC 14882:2011 (Report).
953:(December 1999). ISO/IEC 9899:1999 (Report).
929:C++ In a Nutshell: A Desktop Quick Reference
985:: CS1 maint: numeric names: authors list (
963:: CS1 maint: numeric names: authors list (
744:
706:American National Standards Institute 1990
557:, the functionally equivalent declaration
207:as part of the C standard library. In the
161:
147:
18:
454:, as these statements are not evaluated.
308:macro. This program will always evaluate
912:(2nd ed.). Hoboken: Prentice Hall.
717:
768:
611:
95:
29:
21:
978:
956:
618:
824:American National Standards Institute
756:
7:
211:programming language, assert.h and
686:University of California, Berkeley
520:, serves a similar purpose to the
14:
680:Reekie, John (December 7, 1995).
1017:Swaminathan, Jeganathan (2017).
435:#define assert(ignore) ((void)0)
426:is defined as a macro name, the
324:and does not point to a valid
1:
781:Ballman & Grammatech 2018
733:ISO/IEC JTC 1/SC 22/WG21 2012
646:ISO/IEC JTC 1/SC 22/WG14 1999
302:Below is a program using the
289:type. Two common uses of the
931:(2nd ed.). Sebastopol:
682:"How to use assertions in C"
631:Kernighan & Ritchie 1988
561:was added. assert.h defines
285:macro explicitly allows any
659:"Linux Programmer's Manual"
295:macro are to assert that a
1066:
1050:C standard library headers
910:The C Programming Language
463:macro does not include an
16:Header file for C programs
1019:Mastering C++ Programming
877:(5th ed.). Hoboken:
830:. Summit: Silicon Press.
480:"Not Orwellian"
998:(6th ed.). London:
973:ISO/IEC JTC 1/SC 22/WG21
951:ISO/IEC JTC 1/SC 22/WG14
854:(2nd ed.). Boston:
798:Free Software Foundation
397:
330:
43:Character classification
994:Prata, Stephen (2013).
873:Gregoire, Marc (2021).
850:Binder, Robert (2000).
203:assert.h is defined in
196:and implements runtime
927:Lischner, Ray (2009).
569:to ensure parity with
408:The definition of the
261:, respectively. Since
403:Aborted (core dumped)
96:Miscellaneous headers
432:macro is defined as
275:macro is defined as
450:statements contain
800:. February 6, 2023
759:, p. 762-763.
633:, p. 253-254.
524:macro. Unlike the
182:C standard library
88:Alternative tokens
23:C standard library
1000:Pearson Education
661:. August 25, 2002
184:. It defines the
171:
170:
73:Memory allocation
58:File input/output
1057:
1036:
1013:
990:
984:
976:
968:
962:
954:
946:
923:
902:Kernighan, Brian
897:
892:
875:Professional C++
869:
846:
841:
810:
809:
807:
805:
790:
784:
778:
772:
766:
760:
754:
748:
745:Swaminathan 2017
742:
736:
730:
721:
715:
709:
703:
697:
696:
694:
692:
677:
671:
670:
668:
666:
655:
649:
643:
634:
628:
622:
616:
597:to be included.
596:
592:
584:
580:
568:
565:as an alias for
564:
560:
541:
540:
531:
527:
523:
516:macro, added in
515:
503:
502:
499:
496:
493:
490:
487:
484:
481:
478:
475:
462:
461:
449:
448:
443:
442:
437:
436:
431:
430:
425:
424:
419:
418:
413:
412:
404:
401:
391:
388:
385:
382:
379:
376:
373:
370:
367:
364:
361:
358:
355:
352:
349:
346:
343:
340:
337:
336:<assert.h>
334:
319:
318:
313:
312:
307:
306:
294:
293:
284:
283:
274:
273:
268:
260:
256:
248:
242:
236:
235:
222:
221:
218:
215:
195:
194:
163:
156:
149:
136:
127:
118:
109:
19:
1065:
1064:
1060:
1059:
1058:
1056:
1055:
1054:
1040:
1039:
1033:
1016:
1010:
993:
977:
971:
955:
949:
943:
926:
920:
906:Ritchie, Dennis
900:
895:
889:
872:
866:
849:
844:
838:
822:
819:
814:
813:
803:
801:
792:
791:
787:
779:
775:
767:
763:
755:
751:
743:
739:
731:
724:
720:, p. 1058.
716:
712:
704:
700:
690:
688:
679:
678:
674:
664:
662:
657:
656:
652:
644:
637:
629:
625:
617:
613:
608:
603:
594:
581:was renamed to
538:
510:
500:
497:
494:
491:
488:
485:
482:
479:
476:
473:
459:
446:
440:
434:
428:
422:
416:
410:
406:
405:
402:
399:
393:
392:
389:
386:
383:
380:
377:
374:
371:
368:
365:
362:
359:
356:
353:
350:
347:
344:
341:
338:
335:
332:
326:memory location
316:
310:
304:
291:
281:
271:
244:
238:
233:
229:
219:
216:
213:
192:
167:
130:
121:
112:
103:
78:Process control
17:
12:
11:
5:
1063:
1061:
1053:
1052:
1042:
1041:
1038:
1037:
1031:
1021:. Birmingham:
1014:
1008:
991:
969:
947:
941:
933:O'Reilly Media
924:
918:
898:
893:
887:
870:
864:
856:Addison-Wesley
847:
842:
836:
818:
815:
812:
811:
785:
773:
761:
749:
737:
735:, p. 134.
722:
710:
698:
672:
650:
648:, p. 169.
635:
623:
621:, p. 860.
610:
609:
607:
604:
602:
599:
579:_Static_assert
567:_Static_assert
559:_Static_assert
509:
506:
469:comma operator
467:. However the
398:
331:
277:signed integer
228:
225:
186:C preprocessor
169:
168:
166:
165:
158:
151:
143:
140:
139:
138:
137:
128:
119:
110:
98:
97:
93:
92:
91:
90:
85:
80:
75:
70:
65:
60:
55:
50:
45:
40:
32:
31:
30:General topics
27:
26:
15:
13:
10:
9:
6:
4:
3:
2:
1062:
1051:
1048:
1047:
1045:
1034:
1032:9781786461629
1028:
1024:
1020:
1015:
1011:
1009:9780133432381
1005:
1001:
997:
996:C Primer Plus
992:
988:
982:
974:
970:
966:
960:
952:
948:
944:
942:9781449378837
938:
934:
930:
925:
921:
919:9780131103627
915:
911:
907:
903:
899:
894:
890:
888:9781119695455
884:
880:
876:
871:
867:
865:9780201809381
861:
857:
853:
848:
843:
839:
837:9780929306070
833:
829:
825:
821:
820:
816:
799:
795:
789:
786:
782:
777:
774:
770:
765:
762:
758:
753:
750:
747:, p. 13.
746:
741:
738:
734:
729:
727:
723:
719:
718:Gregoire 2021
714:
711:
708:, p. 76.
707:
702:
699:
687:
683:
676:
673:
660:
654:
651:
647:
642:
640:
636:
632:
627:
624:
620:
615:
612:
605:
600:
598:
591:static_assert
588:
583:static_assert
576:
572:
563:static_assert
556:
551:
549:
545:
539:static_assert
535:
530:static_assert
519:
514:static_assert
508:static_assert
507:
505:
470:
466:
465:error message
455:
453:
396:
329:
327:
323:
314:as false, as
300:
298:
288:
278:
264:
252:
249:, defined in
247:
241:
226:
224:
210:
206:
201:
199:
190:
187:
183:
179:
175:
164:
159:
157:
152:
150:
145:
144:
142:
141:
134:
129:
125:
120:
116:
111:
107:
102:
101:
100:
99:
94:
89:
86:
84:
81:
79:
76:
74:
71:
69:
66:
64:
61:
59:
56:
54:
51:
49:
46:
44:
41:
39:
36:
35:
34:
33:
28:
24:
20:
1018:
995:
928:
909:
874:
851:
827:
817:Bibliography
802:. Retrieved
794:"GNU Gnulib"
788:
783:, p. 1.
776:
771:, p. 3.
769:Gustedt 2022
764:
752:
740:
713:
701:
689:. Retrieved
675:
663:. Retrieved
653:
626:
614:
552:
534:compile-time
511:
456:
452:side effects
407:
394:
322:null pointer
301:
230:
202:
173:
172:
105:
68:Localization
981:cite report
959:cite report
619:Binder 2000
178:header file
53:Mathematics
757:Prata 2013
601:References
38:Data types
804:March 14,
691:March 14,
665:March 14,
606:Citations
243:and call
198:assertion
63:Date/time
1044:Category
908:(1988).
826:(1990).
595:assert.h
589:defines
532:runs at
333:#include
267:__FUNC__
259:__LINE__
255:__FILE__
251:stdlib.h
174:assert.h
133:stdarg.h
124:setjmp.h
106:assert.h
544:Boolean
528:macro,
375:pointer
357:pointer
317:pointer
311:pointer
297:pointer
246:abort()
217:cassert
180:in the
115:errno.h
83:Signals
48:Strings
1029:
1006:
939:
916:
885:
862:
834:
587:Gnulib
526:assert
522:assert
474:assert
460:assert
447:assert
441:NDEBUG
429:assert
423:NDEBUG
417:NDEBUG
411:assert
381:return
369:assert
305:assert
292:assert
287:scalar
282:assert
272:assert
240:stderr
234:assert
205:ANSI C
200:in C.
193:assert
25:(libc)
1023:Packt
879:Wiley
573:. In
548:C++17
518:C++11
420:. If
320:is a
189:macro
176:is a
1027:ISBN
1004:ISBN
987:link
965:link
937:ISBN
914:ISBN
883:ISBN
860:ISBN
832:ISBN
806:2023
693:2023
667:2023
512:The
457:The
351:void
342:main
257:and
231:The
220:>
214:<
135:>
131:<
126:>
122:<
117:>
113:<
108:>
104:<
575:C23
571:C++
555:C11
553:In
501:));
339:int
263:C99
227:Use
209:C++
1046::
1025:.
1002:.
983:}}
979:{{
961:}}
957:{{
935:.
904:;
881:.
858:.
796:.
725:^
684:.
638:^
577:,
504:.
495:==
477:((
378:);
345:()
328::
1035:.
1012:.
989:)
967:)
945:.
922:.
891:.
868:.
840:.
808:.
695:.
669:.
498:5
492:2
489:+
486:2
483:,
390:}
387:;
384:0
372:(
366:;
363:0
360:=
354:*
348:{
162:e
155:t
148:v
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.