Detect platform at compile-time

  • Thread starter Thread starter Mikael
  • Start date Start date
M

Mikael

Is it possible to detect the targeted platform at
compilation time?

I have some code that should be executed on the device
only (ARMV4) not in the emulator (x86).

I've been looking for a conditional compilation statement
("#if...") to use, but have not found one.

Regards,
Mikael
 
Not directly because the code generated by a Smart Device project is in
intermediate code and therefore platform agnostic. However you can set up
within your project multiple configurations - with different destinations
for the compiled exe (or dll) - A project will have Debug and Release
configurations by default you could add a "Desktop" configuration to this.
Build > Configuration Manager then select New from the Drop Down list

You can then define a constant for this configuration - e.g. DESKTOP
Project > ProjectName Properties > Configuration Properties > Conditional
Compilation Constants - add to the list (separate with semi colon)

You can then use conditional compilation to perform different actions for
the desktop and device configurations e.g.
#if DESKTOP
//call desktop specific function
#else
//call device function
#endif

Peter
 
Note also when setting the project properties for the DESKTOP
configuration - to change the output folder for the build - by default
bin/Release but this will overwrite your device dll when you compile so
change to a new output folder such as bin/Desktop. Note to build the two
versions of the project you will need to build one, switch configurations
and rebuild the other when you make changes to the code.

Peter

--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org
 
Back
Top