How to add preprocessor macros in VS code with NCS.

Hi there,

We are quite new to Zephyr. We are currently porting our existing app onto Zephyr as a test. We are currently using NCS 2.5.1

So for our existing application running in IAR, we have different build configurations. The one build configuration is "debug", in which serial logging and other debugging tools is enabled. The other build configuration is release, which is optimized and does not include debugging tools like serial logging in the build (does not configure the uart or use it ever).

For the different build configurations, we then provide different preprocessor macros, for example RELEASE for the release build and DEBUG for the debug build. In the code then, we can use the following:

 #ifndef RELEASE
    //Do something for DEBUG build
 #else
    //Do something for RELEASE build
 #endif
\

However we cant seem to provide preprocessor macros, unless we are overlooking it. I cant imagine that it is not possible to do this. So in the above statement, the #else clause is always true since RELEASE can never be defined.

Does not seem to be easy to have different project settings for different build configurations, as changing the proj.conf and cmakelists.txt file seems to change settings project wide (on all build configs).

Regards,

Frikkie

Related