i'm looking for something like __Darwin__, __Linux__, etc for nuttx
so that i can have something like the following in my app.

#ifdef __NuttX__
#include <nuttx/compiler.h>
#endif

i found some Make.defs defining -D__NuttX__.
is it commonly used?

In general, those definitions come from the compiler, not from the NuttX code.  For example, __Linux__ is defined by an arm-linux-eabi-gcc compiler.  __NUTTX__ will similarly be defined by the arm-nuttx-eabi-gcc compiler generated from https://bitbucket.org/nuttx/buildroot/src/master/

You can add that to your Make.defs file if you like.  It will work in some cases but not in others.  It is a partial but improper solution that may or may not work for you.  The proper solution is to have the definition provided by the toolchain as is done with Linux.  NuttX can never support a common definition within the OS (because such a solution is imperfect).


Reply via email to