How do I know my target platform at compile time?

  • Thread starter Thread starter Rob Richardson
  • Start date Start date
R

Rob Richardson

Greetings!

I am writing components that will be used on both WinXP desktop apps and
WinCE PocketPC apps. If there is code that will differ for the two
platforms (such as form size), is there a constant or something available
that I can use to wrap code in?

#if UNKNOWN_PLATFORM_FLAG_IS_CE
do_ce_thing();
#else
do_xp_thing();
#endif

Thanks!

Rob Richardson
 
Rob Richardson said:
I am writing components that will be used on both WinXP desktop apps and
WinCE PocketPC apps. If there is code that will differ for the two
platforms (such as form size), is there a constant or something available
that I can use to wrap code in?

#if UNKNOWN_PLATFORM_FLAG_IS_CE
do_ce_thing();
#else
do_xp_thing();
#endif

You can use whatever symbol you like - and then just define it in the
build configuration for that platform.
 
Jon,

Yes, I know. I was just hoping that there was a predefined constant already
provided so that I don't have to remember to go in and set my constant for
every configuration of every project.

By the way, I noticed that setting a definition for "All configurations"
doesn't act the way I expected it to. When I create a project, the Debug
configuration has "DEBUG;TRACE" defined and the Release configuration has
"TRACE" defined. I wanted to add "CE" to both of them. So I selected "All
configurations" and entered "CE". When I went back in to the Debug and
Release configurations, I found that the only definition was "CE". The
DEBUG and TRACE defintiions had disappeared.

Rob
 
Rob Richardson said:
Yes, I know. I was just hoping that there was a predefined constant already
provided so that I don't have to remember to go in and set my constant for
every configuration of every project.

Nope - otherwise how is the compiler meant to know which to set? You've
got to tell it which configuration is meant to be for what *somewhere*
- the symbol definition is as good a place as any.
By the way, I noticed that setting a definition for "All configurations"
doesn't act the way I expected it to. When I create a project, the Debug
configuration has "DEBUG;TRACE" defined and the Release configuration has
"TRACE" defined. I wanted to add "CE" to both of them. So I selected "All
configurations" and entered "CE". When I went back in to the Debug and
Release configurations, I found that the only definition was "CE". The
DEBUG and TRACE defintiions had disappeared.

I hadn't tried that myself. It does seem a bit of a missed opportunity.
 
Back
Top