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: 261
Registered: ‎08-11-2009
My Device: Not Specified
Accepted Solution

preprocessing issue

Hi,

 

I  want to use preprocessor in my eclipse for using same code for different  BB OS.

 

i did the following

 

In jdp file:

 

-define=PREPROCESSOR;VER_4_7_AND_ABOVE

 

in  code:

//#preprocessor      // first line 

 

//#ifdef VER_4_7_AND_ABOVE

 

    //System.out.println("works 4.7")

 

 

 

//#endif.

but still it is not working can any one tell why it is not working ,na d how can i solve this issue

 

Thanks

sujithRavindran

 

 

Developer
Posts: 16,687
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: preprocessing issue

put

//#preprocess

in the first line

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 261
Registered: ‎08-11-2009
My Device: Not Specified

Re: preprocessing issue

Hi

 

 

//#preprocess   // first line

 

// inside the constructor

 

    //#ifdef VER_4_7_AND_ABOVE        

        // Dialog.alert("test");
        /* System.out.println("testing");*/
        //#endif

 

 

Thanks

sujithRavindran

Developer
Posts: 261
Registered: ‎08-11-2009
My Device: Not Specified

Re: preprocessing issue

im using eclipse 3.4.1

Developer
Posts: 261
Registered: ‎08-11-2009
My Device: Not Specified

Re: preprocessing issue

any help plz

Developer
Posts: 77
Registered: ‎01-27-2010
My Device: Bold 9000
My Carrier: AT&T

Re: preprocessing issue

Your code is commented out.  You should comment the preprocessor lines (i.e. #ifdef, #preprocess, #endif) but the regular code should be written normally.

Developer
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: preprocessing issue

That's how your supposed to do it (//#preprocess, //#ifdef, //#endif).

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 77
Registered: ‎01-27-2010
My Device: Bold 9000
My Carrier: AT&T

Re: preprocessing issue

 


rcmaniac25 wrote:

That's how your supposed to do it (//#preprocess, //#ifdef, //#endif).


Yes, I know that those lines should be commented out (and I said that in my previous post) but look at the original poster's code.  The code that the user wants to run is commented out as well.

 

 

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: preprocessing issue

Since Eclipse doesn't know about the BB preprocessing directives, doing the obvious thing:

 

 

//#ifdef VER_4_7_AND_ABOVE
   // 4.7-specific api code here
//#endif

 

generates editor complaints whenever the project is set to a a pre-4.7 JRE. To avoid this, I usually do the following:

 

 

 

//#ifndef VER_4_7_AND_ABOVE
   /*
//#else
   // 4.7-specific api code here
//#endif
//#ifndef VER_4_7_AND_ABOVE
    */
//#endif

 

 

That way, Eclipse thinks that the 4.7 code isn't code, and if VER_4_7_AND_ABOVE is defined, the preprocessor removes the comment delimiters.

 

There are three downsides to this. First, block comments within the 4.7-specific section defeat the trick. Second, the Eclipse editor won't catch bad API calls (the compiler will, though). Third (and most serious for me due to my fingers running on auto-pilot) is that formatting the source will make a huge mess out of the preprocessing directives and of the 4.7-specific code.

 

Nevertheless, this is the only way I have found to deal with Eclipse's ignorance of the BB preprocessor.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: preprocessing issue

Woops, read too quick. Did not see the part that said preprocessor lines should be commented out. Sorry.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.