Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Use the preprocessor

by Retired on ‎02-16-2010 03:27 PM - edited on ‎12-20-2010 11:31 AM by Retired (5,981 Views)

Summary

 

This article applies to the following:

 

  • BlackBerry® Java® Development Environment (BlackBerry JDE)
  • BlackBerry® Java Plug-in for Eclipse®

  • Details


    RIM Application Program Compiler (RAPC) supports a few basic preprocessor directives. The directives can be used to take advantage of features available in later BlackBerry smartphones and builds without fragmenting into multiple code lines, or to make it easy to remove debug output for final versions.

     

    The following directives are supported:

     

     

    Enable the preprocessor
    //#preprocess

    If, else, end if block:
    //#ifdef <tag>

    //#else

    //#endif

     

    If <tag> is defined, then the code between #ifdef and else is executed; otherwise, #else to #endif is executed. The else section is not mandatory.

     

     

     

    If not, else, end if block:
    //#ifndef <tag>

    //#else

    //#endif

     

    #ifndef is the opposite of #ifdef. If <tag> is not defined, the code is executed.

     

    When using the BlackBerry Java Plug-in for Eclipse you must first enable preprocessing using the steps outlined here. After this is done you can set preprocessor defines in the Build tab of the BlackBerry_App_Descriptor.xml file as shown in the following image:

     

Preprocessor_AppDescriptor.PNG

 

 

If the BlackBerry_App_Descriptor.xml file is not present, update the BlackBerry Java Plug-in for Eclipse to the latest available version. If you have not configured Eclipse™ to use the BlackBerry Java Plug-in for Eclipse update site, this can be accomplished by following the steps found here.

 

To use the preprocessor in the BlackBerry JDE, you must manually add it to the Java development project (JDP) file. To do this, complete the following steps:
  1. Open the JDP file with an editor.
  2. Go to the line that starts with Options.
  3. At the end of the line, add -define <tag1>;<tag2>;…;<tagN> as in the following example:

    Options=-quiet -define=FOO;PREPROCESSOR

The -define statement is simply an argument passed to the RAPC. Therefore, you can use it with your own command line build scripts. This functionality has been present since RAPC version 4.0. >f you use the preprocessor, make sure at least one definition is defined, typically PREPROCESSOR, or it will not engage.

Users Online
Currently online: 23 members 2,337 guests
Please welcome our newest community members: