Here is the issue to track debug.h created before:
https://github.com/apache/nuttx/issues/8986

On Wed, Jan 3, 2024 at 2:30 AM Gregory Nutt <spudan...@gmail.com> wrote:

> > On Tue, Jan 2, 2024 at 11:16 AM Fotis Panagiotopoulos
> > <f.j.pa...@gmail.com>  wrote:
> >> DEBUGASSERT shall only be used for the kernel.
> >> assert shall only be used for apps.
> >>
> >> Rationale:
> >>
> >> DEBUGASSERT is a custom macro that only exists in the NuttX world.
> >> As such it is best being used in NuttX-specific code.
> >>
> >> assert on the other hand is a standard function, it exists in all
> systems.
> >> It seems better suited for generic and portable code (i.e. apps).
>
> We have no way to enforce this.  What we do do is at least make it clear
> that the application is using a kernel-only macro or function
> inappropriately by putting the macro definition or function prototype in
> NuttX private file.  For example,
>
>   * Remove the DEBUGASSERT (and ASSERT?) macros from include/assert.h
>   * Add them to include/nuttx/assert.h
>   * All applications that use DEBUGASSERT (or ASSERT) should be changed
>     to use assert()
>   * Kernel functions that use DEBUGASSERT (or ASSERT) would have to
>     explicitly include <nuttx/assert.h>
>
> Not foolproof, but that is how we have dealt this this in the past.  It
> if is in include/assert.h, is is essentially being advertised as OK for
> use by applications.  This is logically equivalent to the Linux/LibC
> conventions of putting Linux-specific files in /usr/include/linux vs.
> normal, standard application files in /usr/include.
>
> There may be some issues in common application/kernel LibC files that
> use DEBUGASSERT (or ASSERT)
>
> This same discussion should also apply to include/debug.h which contains
> only nonstandard debug macros.  Shouldn't it also be moved to
> include/nuttx/debug.h?
>
>

Reply via email to