<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to enable C / C++ asserts?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/118700/how-to-enable-c-c-asserts</link><description>Hi, 
 normally, I would set the CMAKE_BUILD_TYPE to `Debug` to enable Cs &amp;quot;assert&amp;quot; function (not define NDEBUG). Zephyr (and Nordic-Zephyr as well) has the `CONFIG_ASSERT` configuration option but this seems to only enable Zephyrs asserts. How am I&amp;#39;m supposed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 07 Jul 2025 11:42:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/118700/how-to-enable-c-c-asserts" /><item><title>RE: How to enable C / C++ asserts?</title><link>https://devzone.nordicsemi.com/thread/541605?ContentTypeID=1</link><pubDate>Mon, 07 Jul 2025 11:42:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49eb73d2-1edf-4108-bcff-eccb0cf6cd9d</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Zephyr seems to set the NDEBUG on the command line as soon as the build is not a debug build. Using `CONFIG_COMPILER_OPT=&amp;quot;-UNDEBUG&amp;quot;` will add `-UNDEBUG` to the command line and thus will remove the `NDEBUG` definition from the compilation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable C / C++ asserts?</title><link>https://devzone.nordicsemi.com/thread/521852?ContentTypeID=1</link><pubDate>Fri, 07 Feb 2025 06:04:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3267a95-92db-4ac7-9375-b0be17267c28</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Hi Jakob,&lt;/p&gt;
&lt;p&gt;I stumbled over this, by observing asserts, that I thought should fire, but did not. I added an `assert(false)` to my application code and it did not fire. I added&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#ifdef NDEBUG
#undef NDEBUG
#endif

#include &amp;lt;cassert&amp;gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;to the file in question and finally, `assert( false )` fired.&lt;/p&gt;
&lt;p&gt;I have not found anything in my CMakeLists.txt that would add NDEBUG to the set of defines.&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Torsten&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable C / C++ asserts?</title><link>https://devzone.nordicsemi.com/thread/521829?ContentTypeID=1</link><pubDate>Thu, 06 Feb 2025 22:44:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97663341-da41-48fc-a942-03da7deae812</guid><dc:creator>Jakob Ruhe</dc:creator><description>&lt;p&gt;As far as I know Zephyr does not define the symbol `NDEBUG` for you. What makes you think that?&lt;/p&gt;
&lt;p&gt;If you modify the sample application `hello_world` to include `assert.h`&amp;nbsp; and call `assert(0)`. What happens when you run it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>