I am currently hacking around on a new DRM system for my applications which – surprise, surprise – will include OTA wherever its possible (aka at MobiHand’s). As I need to use variable URL’s for each distributor, I felt like using the preprocessor.
As I stumbled across a few interesting things, I felt like sharing the code below:
#if defined MOBIHAND
WBM_OpenWebPage(0,"https://www.mobihand.com/mobilecart/mc1.asp?posid=162&pid=8703");
#elif defined PALMGEAR
WBM_OpenWebPage(0,"http://www.palmgear.com/index.cfm?fuseaction=sc.buy&prodid=137239&buytoken=62745661");
#else
#error "no ESD Specified"
#endif
The first thing that I considered interesting is the #error macro – it allows you to stop the compilation process if some condition is not met. In the example above, the condition would be that no ESD flag is set. Furthermore, nesting definitions isn’t too easy either – the syntax involves the defined operator (which the PODS does NOT highlight).
Related posts: