One option would be to define __NUTTX_ in tools/Config.mk instead of in each individual apps/Makefile. That would provide a single point definition coordinate all usage.
My favorite solution, but not one that is easily fielded would be to use the NuttX buildroot toolchains: https://bitbucket.org/nuttx/buildroot/src/master/ . These generate a nuttx-eab-gcc (toolchain not a none-eabi toolchain) and they have several advantages: (1) they do not use a foreign libc but build directly using the NuttX libc. So they will never generate libc header file conflicts. and (1) they define __NUTTX__ The downside is that, as I recall, they don't build the C++ standard library. On Tue, Feb 22, 2022 at 12:50 PM Gregory Nutt <spudan...@gmail.com> wrote: > I have been working on an application for the past several months. Now > want to get it running on NuttX. I don't have much experience porting > applications to NuttX and have some dumb newbie questions (I mostly worked > on the other side of the application/OS interface). > > If I have an application that builds and runs on Linux and I want to port > it to NuttX, I would basically just provide the Kconfig files, Make.defs > files, and Makefiles as expected by the build system, then just link my > application anywhere in the app/ source tree. > > But how does the code know that it is running on NuttX? There is no > CONFIG_NUTTX, there is no OS_managed __NUTTX__ definition. > > I do see a __NUTTX__ definition defined in some application Makefiles in > apps/, but this is a chicken'n'egg problem. They use custom Makefiles to > provide these definitions. But what if you want the same application build > logic to support either platform. I don't see any way to do that. > > Has anyone thought of way to do this? Or do you all use custom Makefile > for the NuttX build? > > Greg > >