I'm not sure that I'm fully following the discussion (I will read the PR comments to get the full context), but my vote is for: 1. There should be a separate way to build kernel and app with assert() enabled. 2. The assert() should be disabled by default. So the default build is a release build. 3. I do not care if it is a config option or I need to "make NDEBUG=1" from a command line. Probably 2 Kconfig options (one for kernel and 1 for apps would be the best).
Best regards, Petro On Mon, Feb 14, 2022, 7:56 PM David Sidrane <david.sidr...@nscdg.com> wrote: > PR 5399 adds an Kconfig option for NDEBUG. The salient discussion begins at > [2] there are mixed positions and reasoning. xiaoxiang781216 asked me to > raise a discussion on this. > > > > The reasoning for the Default state of to be NDEBUG (n) hence undefined so > that assert() enabled is the following: > > > > 1) It follows the standard understanding of NDEBUG > > > > The standard for standard library from [3] > > > > The definition of the macro assert depends on another macro, > NDEBUG, *which is not defined* by the standard library. > > > > > > 2) We have DEBUGASSERT for use in the OS. I believe this was an > intentional separation on Greg’s part. We have asked for is input. > > > > In a NuttX "Release" build DEGUASSERT is off (all debug is off to show off > the build size). > > I should still be able to build the app code with assert() and not have to > use a Kconfig to enable it. > > How would you prefer it to be defined? > > > > 1. Defaulted ON – assert() is a No OP > 2. Defaulted OFF assert() is enabled. > 3. Left to a command line setting from build system > > > > David > > > > [1] https://github.com/apache/incubator-nuttx/pull/5399 > > > > [2] > https://github.com/apache/incubator-nuttx/pull/5399#issuecomment-1029387606 > > [3] > > https://en.cppreference.com/w/c/error/assert#:~:text=If%20NDEBUG%20is%20defined%20as,the%20source%20code%20where%20%3Cassert.&text=If%20NDEBUG%20is%20not%20defined,output%20and%20calls%20abort() > . >