how to use preprocessors in blackberry to target the code for multiple platforms, any one having any thing on JDE with 4.2 and above
views:
30answers:
2I would recommend an alternative approach - as (IMO) preprocessors can make code hard to manage. This is especially true since Eclipse doesn't seem to recognize preprocessor directives when it comes to evaluating code -- so if you're trying to test on an older simulator, it causes headaches. (Not impossible, just extra hoops to jump through.) For a larger application, this will become easier to manage over time -- although the initial setup is more work.
One alternative is to use inheritance and separate libraries. So your lowest common denominator is your base library. Your OS 4.5 library sits on top of that and extends it with OS 4.5 features; and OS 4.6 extends OS 4.5 content, etc. Your app dependencies would look like this:
- YourApp.cod
- SharedComponents_50.cod
- SharedComponents_46.cod
- SharedComponents_45.cod
- SharedComponents_43.cod
- SharedComponents.cod (lowest level, 4.2)
Most of your features are in your core 4.2 "SharedComponents" library -- only those things which are extended to specific platform versions are in the higher-level libraries. You would ship the 5.0 build of your app with all libraries; while the 4.2 build would ship with only "Your App" and "SharedComponents.cod", and the others would fall in-between.