Using preprocessor is not the way to make A SINGLE BUILD
for different BB OS Versions (No matter what tool you use to prepare the build).
Preprocessors are used just to remove/add particular portion of code based on provided conditions before compiling/building the entire code.
More generally, preprocessors are used to consider the source code differently for different conditions.
More more generally, preprocessors are used to produce different source codes for different conditions.
In such a case the scope of preprocessors is only before compiling/building the code... not after you have build the code and got the executable/.cod/...etc. file
Read first few lines of T H E S E links; though these are about C-Preprocessors, but the basic is also applicable here.
Suppose your code is as following:
// START OF CODE
//#preprocess
// this is the second line of the code
//...
//#ifdef OS_5
import net.rim.device.api.ui.component.AutoCompleteField;
//#else
//don't import AutoCompleteField and import something else if needed
//#endif
//...
//... // some more codes
//...
//#ifdef OS_5
//...
//...
// Codes for using AutoCompleteField
//...
//...
//#else
//...
//...
// Codes for implementing AutoCompleteField another way by yourself
//...
//...
//...
//... // some more codes
//...
// END OF CODE
It doesn't matter what tool you use to build your code (JDE, Eclipse or using Ant), if you build with the preprocessor 'OS_5'
then (if your tool can understand preprocessors) the following code will be generated :
// START OF CODE
// this is the second line of the code
//...
import net.rim.device.api.ui.component.AutoCompleteField;
//...
//... // some more codes
//...
//...
//...
// Codes for using AutoCompleteField
//...
//...
//...
//... // some more codes
//...
// END OF CODE
and the .cod
file will be generated with the above code. And this .cod
file will not run on BB OS Versions less than 5.0 because AutoCompleteField
is supported from OS 5.
And if you build without the preprocessor 'OS_5' or other preprocessors
then the following code will be generated:
// START OF CODE
// this is the second line of the code
//...
//don't import AutoCompleteField and import something else if needed
//...
//... // some more codes
//...
//...
//...
// Codes for implementing AutoCompleteField another way by yourself
//...
//...
//...
//... // some more codes
//...
// END OF CODE
and the .cod
file will be generated using the above code, and This is going to be a different .cod
file than the previous one.
Now if you want to prepare A SINGLE BUILD
and deploy it successfully different BB OS supported devices, then you have to remove dependencies
while coding, i.e. use only those API-classes that are supported by all the OS versions (4.6, 5.0... and others if you want). But it's very difficult sometimes for some cases, because you may have to write your own codes for implementing some features.
It's easier to prepare different builds for different OS --- and on that purpose you can of course use preprocessors..
I'm afraid may be I have explained an easy thing in a very complex way.