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

Reply
Developer
Posts: 54
Registered: ‎11-12-2009
My Device: Not Specified
Accepted Solution

Preprocessor directives for multiple JDEs

Hello,

 

I am working with the preprocessor directives currently, and was able to use it successfully for my sample application.I am using the Blackberry Java Plugin for Eclipse for my development, and have observed that it provides certain predefined directives for all the JDEs ( I am working with JDE 5.0, 6.0, 7.0 and 7.1) While I understand that each preprocessor can correspond to a single JDE only, I want to use a single preprocessor statement  for multiple JDEs.

 

For example instead of :

 

 

//#ifdef BlackBerrySDK6.0.0
        setTitle( "HelloBlackBerry 6.0.0" );
 //#endif

 I want to put a preprocessor that works for JDE 6.0.0 and all JDEs above 6.0.0 :

 

//#ifdef BlackBerrySDK6.0.0 or BlackBerrySDK7.0.0 or BlackBerrySDK7.1.0
        setTitle( "HelloBlackBerry" );
 //#endif

 

In short, can I have logical AND | OR operations amongst the preprocessor directives?

 

Any help will be highly appreciated!

Thanks.

Developer
Posts: 54
Registered: ‎11-12-2009
My Device: Not Specified

Re: Preprocessor directives for multiple JDEs

I figured it out, probably using the | and & operators works :

 

//#ifdef BlackBerrySDK6.0.0 | BlackBerrySDK7.0.0
do something
//#endif

 Though I am amazed how none of the so many articles on preprocessor directives mentions about this!

Developer
Posts: 54
Registered: ‎11-12-2009
My Device: Not Specified

Re: Preprocessor directives for multiple JDEs

Has anyone used a combination of & and | operators in a directive?

 

For example :

 

//#ifdef myPreprocessor & (BlackBerrySDK7.0.0 | BlackBerrySDK7.1.0)

 The compiler gives me an error that a combination of & and | cannot be used with //#if statement..How do I go about achieving this then..