Custom Macro definition in Mbed Studio

Before, I could change the macros and use the macros to select different boards. I could define any macro in the Makefile. .don’t know how to do it with mbed studio. Json file has configuration but how should you define your custom macro?


will make this if valid using Makefile

#include “nucleo_l476rg_hw.h”

How should I do or how to detect which HW is used in Mbed Studio so a specific header will be included?
The code I have supports different boards, based on the target it should choose the correct header.
The above if processor is failing and it doesn’t select the correct header file when I compile for a specific target defined by the MBED studio target selection.


for something like that you do not need custom macros, you have to check if was defined.

#if defined(TARGET_NUCLEO_L476RG)
#include "something.h"

This is best option to do a customatizion based on target selection without any special attention from your side.
However if you still want to use a custom macro, then you can do it via mbed_app.json like below.

then when you can found it close to end of mbed_config.h (read only) at location ProjectName\BUILD\TargetName\CompilerName\

Of course the clean build have to be triggered after any change.

BR, Jan

Hi, thank you very much. So, it should be before target_overrides? right?

It does not matter if is before or after I think, but probably not inside because this is for overriding the configuration from targets.json file.

BR, Jan