Skip to main content
BParh.1
Senior III
September 14, 2021
Solved

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

  • September 14, 2021
  • 2 replies
  • 835 views

Sample usage:

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

This topic has been closed for replies.
Best answer by Romain DIELEMAN

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

2 replies

Romain DIELEMAN
Romain DIELEMANBest answer
ST Employee
September 14, 2021

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
September 16, 2021

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
September 16, 2021

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

/Romain