I have a project which needs to be used in 4.6 and 5.0 versions of blackberry.
I have run same code in both the 4.6 and 5.0 versions with some preprocessor directives attached to the code (#ifndef statements which i need to use for 5.0 as facebook sdk is not supported in 4.6 version)
I have 2 .cod files ( one for 4.6 and other for 5.0)
they work as needed in their respective simulators.
But, when i load the .cod file of 4.6 into 5.0 … (it treats it as the code inside preprocessor as comment)
and when i do it viceversa
ie from 5.0 into 4.6 … it says … projectname-1.cod not found .
A similar question is been posted here too check out where a comment on bbtool says it can be possible
One build for two different versions (4.6,4.7 and 5.0+above) in blackberry
Using preprocessor is not the way to make
A SINGLE BUILDfor 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:
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 :and the
.codfile will be generated with the above code. And this.codfile will not run on BB OS Versions less than 5.0 becauseAutoCompleteFieldis supported from OS 5.And if you build without the preprocessor ‘OS_5’ or other preprocessors
then the following code will be generated:
and the
.codfile will be generated using the above code, and This is going to be a different.codfile than the previous one.Now if you want to prepare
A SINGLE BUILDand deploy it successfully different BB OS supported devices, then you have toremove dependencieswhile 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.