Loading...
 
Skip to main content

System Workbench for STM32


Detecting active build config at compile time

Newbie on the site using NUCLEO-F767ZI - forgive me any unintended indiscretions, but do point them out so I can learn.

How do I detect which build config is active at time of compilation?

If DEBUG is active then I want to printf info to the console
otherwise send the same info via UART

Code example ...

  1. ifdef DEBUGactive

printf(...);

  1. else

send(...);

  1. endif
France

Hi,

You're almost right in your guess: use #ifdef DEBUG and it will work 😎

Bernard (Ac6)


hi

ich have one projekt with 3 different targets

so i configured 3 different build configurations.

"TEST_A" : symbols: TEST_A
"TEST_B" : symbols: TEST_B ; FEATURE_B
"TEST_C" : symbols: TEST_B ; FEATURE_C

BUT:
In my sources i use preprocessor switches ( #ifdef / #endif ) to select the functions.

but i cant see any changes in highlighting in sources.
it seems it compiles correctly ... but you can't see the changes if you switch the active build configuration.

is there a "trick" ?


EDIT:

i can use i any headerfile #define TEST_A ...
but i think this is also possible with different configurations like "Debug/Release"