<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[assert Beispiel]]></title><description><![CDATA[<blockquote>
<p>When you are developping, use the assert macro to detect errors as soon as they occur. This macro is defined in the include file &lt;assert.h&gt;, and is used that way :</p>
<p>assert (expression) ;</p>
<p>If expression is false, program will stop indicating which assertion failed.</p>
<p>What is really nice with this macro, is that you can easily get rid of it for the production version of your code, by declaring #define NDEBUG.</p>
<p>This is because the assert macro is defined as :</p>
<p>#ifndef NDEBUG<br />
#define assert(THETEST) ...<br />
#else<br />
#define assert(THETEST) ((void)0)<br />
#endif</p>
</blockquote>
<p>das funktioniert aber nicht:</p>
<pre><code>#include &lt;assert.h&gt;

void main()
{
  assert(1 ==2);
}
</code></pre>
<p>wenn ich as Inclusion</p>
<pre><code>#include &lt;assert.h&gt;
#define NDEBUG
</code></pre>
<p>definiert, assert(1 == 2) ist immer noch nicht deaktiviert.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/135428/assert-beispiel</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 00:10:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/135428.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 02 Feb 2006 08:43:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to assert Beispiel on Thu, 02 Feb 2006 08:43:36 GMT]]></title><description><![CDATA[<blockquote>
<p>When you are developping, use the assert macro to detect errors as soon as they occur. This macro is defined in the include file &lt;assert.h&gt;, and is used that way :</p>
<p>assert (expression) ;</p>
<p>If expression is false, program will stop indicating which assertion failed.</p>
<p>What is really nice with this macro, is that you can easily get rid of it for the production version of your code, by declaring #define NDEBUG.</p>
<p>This is because the assert macro is defined as :</p>
<p>#ifndef NDEBUG<br />
#define assert(THETEST) ...<br />
#else<br />
#define assert(THETEST) ((void)0)<br />
#endif</p>
</blockquote>
<p>das funktioniert aber nicht:</p>
<pre><code>#include &lt;assert.h&gt;

void main()
{
  assert(1 ==2);
}
</code></pre>
<p>wenn ich as Inclusion</p>
<pre><code>#include &lt;assert.h&gt;
#define NDEBUG
</code></pre>
<p>definiert, assert(1 == 2) ist immer noch nicht deaktiviert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/983677</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/983677</guid><dc:creator><![CDATA[netrobot]]></dc:creator><pubDate>Thu, 02 Feb 2006 08:43:36 GMT</pubDate></item><item><title><![CDATA[Reply to assert Beispiel on Thu, 02 Feb 2006 08:47:33 GMT]]></title><description><![CDATA[<p>erst define dann include?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/983680</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/983680</guid><dc:creator><![CDATA[!!!]]></dc:creator><pubDate>Thu, 02 Feb 2006 08:47:33 GMT</pubDate></item><item><title><![CDATA[Reply to assert Beispiel on Thu, 02 Feb 2006 09:43:30 GMT]]></title><description><![CDATA[<p>!!! schrieb:</p>
<blockquote>
<p>erst define dann include?</p>
</blockquote>
<p>Genau. Besser ist aber, dass Makro NDEBUG projektweit (über einen passenden Compilerschalter wie z.B. -D beim gcc) zu setzen. So hat man dann auch garantiert überall die gleiche Ersetzung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/983725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/983725</guid><dc:creator><![CDATA[HumeSikkins]]></dc:creator><pubDate>Thu, 02 Feb 2006 09:43:30 GMT</pubDate></item></channel></rss>