<?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[Debug-Klasse mit Assertions]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich suche eine Debug-Klasse, die etwas ähnliches wie eine Assertion ermöglicht,<br />
wobei aber _global_ konfigurierbar sein soll, wie darauf reagiert wird. Pseudo-<br />
code:</p>
<pre><code>debugClass.setBehavior(JUST_WARN);
debugClass.myAssert(bool someCondition,string message);
</code></pre>
<p>Ein 'false' sollte dann je nach Konfiguration von debugClass entweder zum<br />
Abbruch führen oder bloß ein Warning schreiben und weiter machen oder auch<br />
eine Exception werfen. Ich nehme an, daß ähnliche Debug-Klassen schon fertig<br />
existieren?</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/290159/debug-klasse-mit-assertions</link><generator>RSS for Node</generator><lastBuildDate>Tue, 18 Aug 2026 17:39:20 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/290159.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 20 Jul 2011 14:38:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Debug-Klasse mit Assertions on Wed, 20 Jul 2011 14:38:34 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich suche eine Debug-Klasse, die etwas ähnliches wie eine Assertion ermöglicht,<br />
wobei aber _global_ konfigurierbar sein soll, wie darauf reagiert wird. Pseudo-<br />
code:</p>
<pre><code>debugClass.setBehavior(JUST_WARN);
debugClass.myAssert(bool someCondition,string message);
</code></pre>
<p>Ein 'false' sollte dann je nach Konfiguration von debugClass entweder zum<br />
Abbruch führen oder bloß ein Warning schreiben und weiter machen oder auch<br />
eine Exception werfen. Ich nehme an, daß ähnliche Debug-Klassen schon fertig<br />
existieren?</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2095448</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095448</guid><dc:creator><![CDATA[bts3]]></dc:creator><pubDate>Wed, 20 Jul 2011 14:38:34 GMT</pubDate></item><item><title><![CDATA[Reply to Debug-Klasse mit Assertions on Wed, 20 Jul 2011 15:16:24 GMT]]></title><description><![CDATA[<p>Musst du das Verhalten während der Laufzeit ändern können? Dann musst du dich noch um Multithreading etc. kümmern. Einfacher wäre es, mit dem Präprozessor die richtige Variante auszuwählen:</p>
<pre><code class="language-cpp">#ifdef MY_ASSERT_CALL_ABORT
  #define MY_ASSERT(expr) assert(expr);
// etc.
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2095467</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095467</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Wed, 20 Jul 2011 15:16:24 GMT</pubDate></item><item><title><![CDATA[Reply to Debug-Klasse mit Assertions on Wed, 20 Jul 2011 19:02:23 GMT]]></title><description><![CDATA[<p>Die C Standardbibliothek hat etwas schönes: <code>assert.h</code></p>
<p>Das arbeitet mit <code>#define</code> s und den <code>#if</code> s wie Michael schon angesprochen hat.</p>
<p>Falls du #defines nicht leiden kannst, man kan sicherlich den code in funktionen per #ifndef NODEBUG ausschneiden, der compiler sollte den Aufruf gänzlich wegschmeißen, und es regnet optimierten code duch die CPU, die zufrieden und gelassen lächelt. (oder nicht?)</p>
<p>Kann jetzt keinen funktionierenden Code garantieren, aber....</p>
<pre><code class="language-cpp">// myownasserts.h

// before of this inclusion you set the tag NODEBUG

class AssertAttack
{
public:
    inline static bool assert_int_equality(int a, int b)
    {
        #ifndef NODEBUG
        return a == b;
        #endif
    }

    // etc
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2095617</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095617</guid><dc:creator><![CDATA[lk]]></dc:creator><pubDate>Wed, 20 Jul 2011 19:02:23 GMT</pubDate></item><item><title><![CDATA[Reply to Debug-Klasse mit Assertions on Wed, 20 Jul 2011 19:03:38 GMT]]></title><description><![CDATA[<p>lk schrieb:</p>
<blockquote>
<p>Die C Standardbibliothek hat etwas schönes: <code>assert.h</code></p>
</blockquote>
<p>In C++ nehmen wir jedoch #include &lt;cassert&gt;<br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2095618</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095618</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Wed, 20 Jul 2011 19:03:38 GMT</pubDate></item><item><title><![CDATA[Reply to Debug-Klasse mit Assertions on Wed, 20 Jul 2011 19:17:06 GMT]]></title><description><![CDATA[<p>314159265358979 schrieb:</p>
<blockquote>
<p>lk schrieb:</p>
<blockquote>
<p>Die C Standardbibliothek hat etwas schönes: <code>assert.h</code></p>
</blockquote>
<p>In C++ nehmen wir jedoch #include &lt;cassert&gt;<br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
</blockquote>
<p>Nein nein, ich meinte jetzt nicht man solle die C version verwenden. Insbesondere da ich immer noch mit printf() debugge und assertions nicht kenne.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2095633</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095633</guid><dc:creator><![CDATA[lk]]></dc:creator><pubDate>Wed, 20 Jul 2011 19:17:06 GMT</pubDate></item></channel></rss>