views:

30

answers:

2

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

A: 

read this article preprocessor directives for blackberry

Vivart
this is for 4.5 and above can we not do it for code of 4.2?
SoftReference
only example is given for 4.5. i think this will work for 4.2 also.
Vivart
A: 

I 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.

Marc Paradise
deploying and managing the dependent .cod-s may be a headache. People often don't like preprocessors but it may be easier in the real world.
seand
If you're willing to do deployment builds with a different process from your development environment, this is a solvable problem. For deployment, build with Ant, and make each platform build use a fileset containing all relevant source directories. That way, you get a single monolithic COD for each platform.
octo