I have developed a chat application on BlackBerry OS 5.0 but my client wants me to make it portable to all the platforms from 4.5 to 5.0 and above. I have tried using preprocessor directives to compile the OS compatible classes at run time, but I haven't succeeded in it yet. I doubt the way I'm using preprocessors. so I'm putting up an example here:
//#ifdef JDE_4_6_0_AND_ABOVE
/*
//#endif
//some code
//#ifdef JDE_4_6_0_AND_ABOVE
*/
//#endif
//#ifndef JDE_4_6_0_AND_ABOVE
/*
//#endif
//Alternative of code used above
//#ifndef JDE_4_6_0_AND_ABOVE
*/
//#endif
this is the way I'm doing it for the particular part of the code. The logic here is to use first code if OS version is 4.6 and above...and to use the second code if OS version is below 4.6....
But the code under preprocessors doesn't seem to compile in either of the case.
Note: I have put "//#preprocess" at the start of the code and defined the preprocessors in my application descriptor xml file, but still no luck. Also is there any other solution to handling compatibility between BBOS versions?
You are placing the code outside the statements. ifdef and ifndef open the statements, endif closes the statement. You can also use #else as you only have two cases.
//#ifdef JDE_4_6_0_AND_ABOVE
System.out.println("JDE_4_6_0_AND_ABOVE");
//#else
System.out.println("NOT JDE_4_6_0_AND_ABOVE");
//#endif
Cheers
Ray
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With