I want to pass a variable to my program so I'm using the command:
west build -b nrf52840dk_nrf52840 -p --build-dir build -- -Dmy_variable=40
Then in my program I want to print it:
int main()
{
#ifdef my_variable
printf("my_variable = %i",my_variable);
#else
printf("my_variable is not defined");
#endif
}But the result is "my_variable is not defined". What am I doing wrong?