From WikiChip
Editing c/assert.h

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.

Latest revision Your text
Line 1: Line 1:
{{c title|<assert.h> Header}}{{C Standard Library}}
+
{{DISPLAYTITLE:<assert.h> Header - C}}
 +
{{C Standard Library}}
 
The '''<assert.h>''' header is part of the [[standard library]] of the [[C programming language]] that provides two macros that implement an assertion - a way to verify that some assumption made by the code is true. If the assumption was false, a diagnostic message gets printed. The header provides both a run-time assertion and a compile-time assertion.
 
The '''<assert.h>''' header is part of the [[standard library]] of the [[C programming language]] that provides two macros that implement an assertion - a way to verify that some assumption made by the code is true. If the assumption was false, a diagnostic message gets printed. The header provides both a run-time assertion and a compile-time assertion.
  
Line 5: Line 6:
  
 
== Debug mode ==
 
== Debug mode ==
The header depends on another macro {{C|NDEBUG}} which is not defined by <assert.h> itself. If NDEBUG is defined as a macro name at the point in the source file where <assert.h> is included, the assert macro behave as if they were noops - with absolutely no effect on the program.
+
The header depends on another macro [[NDEBUG - C|NDEBUG]] which is not defined by <assert.h> itself. If NDEBUG is defined as a macro name at the point in the source file where <assert.h> is included, the assert macro behave as if they were noops - with absolutely no effect on the program.
  
 
<source lang="c">#define NDEBUG
 
<source lang="c">#define NDEBUG
Line 18: Line 19:
 
! Macro Name !! Description !! Since
 
! Macro Name !! Description !! Since
 
|-
 
|-
| {{C|Assert.h/assert|assert}} || implements a run-time assertion || [[C89]]
+
| [[Assert.h/assert - C|assert]] || implements a run-time assertion || [[C89]]
 
|-
 
|-
| {{C|Assert.h/static_assert|static_assert}} || implements a compile-time assertion || [[C11]]
+
| [[Assert.h/static_assert - C|static_assert]] || implements a compile-time assertion || [[C11]]
 
|}
 
|}
  
 
== Diagnostic message ==
 
== Diagnostic message ==
  
An example of the diagnostic message as a result of the {{C|Assert.h/assert|assert}} macro is:
+
An example of the diagnostic message as a result of the [[Assert.h/assert - C|assert]] macro is:
  
 
<pre>Assertion failed: data != NULL, function load_data, file foo.c, line 94.</pre>
 
<pre>Assertion failed: data != NULL, function load_data, file foo.c, line 94.</pre>
  
 
== Run-time assertion ==
 
== Run-time assertion ==
'''Run-time assertion''' refers to the ability to assert a certain condition during the execution of the program. The {{C|assert}} macro provides such facilities. Checking the certain conditions are true during the execution of a program is crucial for validating that an algorithm is performing correctly.
+
'''Run-time assertion''' refers to the ability to assert a certain condition during the execution of the program. The [[assert - C|assert]] macro provides such facilities. Checking the certain conditions are true during the execution of a program is crucial for validating that an algorithm is performing correctly.
  
 
== Compile-time assertion ==
 
== Compile-time assertion ==
'''Compile-time assertion''' refers to the ability to assert a certain condition during the compilation stage, provided the condition evaluates to a compile-time constant. The {{C|Assert.h/static_assert|static_assert}} macro provides the facilities for a compile-time assertion.
+
'''Compile-time assertion''' refers to the ability to assert a certain condition during the compilation stage, provided the condition evaluates to a compile-time constant. The [[Assert.h/static_assert - C|static_assert]] macro provides the facilities for a compile-time assertion.
  
{{DEFAULTSORT:Assert.h}}
+
{{DEFAULTSORT:Assert.h - C}}
 
[[Category:C standard library]]
 
[[Category:C standard library]]
 
[[Category:assert.h - C]]
 
[[Category:assert.h - C]]
[[Category:Assertion - C]]
 

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)