Skip to main content
BParh.1
Senior III
Solved

Is there macro can be used as compilation switch to differentiate between build for simulator vs for HW target?

Sample usage:

I want to have different settings when working in hardware vs working on simulator

This topic has been closed for replies.
Romain DIELEMAN
Romain DIELEMANBest answer
ST Employee

Hi,

If you wish to add code only for when running with the simulator you can wrap the particular code (UI components and logic) in something like this:

#ifdef SIMULATOR
 
//...
 
#endif

Don't know if there is the equivalent for just running on hardware.

/Romain

3 replies

Romain DIELEMAN
Romain DIELEMANBest answer
ST Employee

Hi,

If you wish to add code only for when running with the simulator you can wrap the particular code (UI components and logic) in something like this:

#ifdef SIMULATOR
 
//...
 
#endif

Don't know if there is the equivalent for just running on hardware.

/Romain

BParh.1
BParh.1Author
Senior III

Thank you @Romain DIELEMAN

Anyway for my knowledge, while the macro seems to work, but I could not see in the simulator .sln project code it is defined. So where is this macro 'SIMULATOR' defined?

Romain DIELEMAN
ST Employee

I don't know to be honest, I'll try to check

/Romain