开发者

Blackberry preprocessor in eclipse

I have a doubt about blackberry preprocessing. I am using eclipse and maintaining a codebase which is compatible with both touch based devices and qwerty devices. Now the well known problem with eclipse is... when you change the blackberry installed component of 4.5, it started showing out compilation errors for touch specific API parts even though I put them inside preprocessor blocks. Note that the same code dont give any error in JDE when compiled under 4.7 and 4.5.

I followed a tip from http://smartfone-more.blogspot.com/2010/05/coding-for-multiple-blackberry-devices.html, which block comments the //#ifdef with two blocks of //ifndef.

Basically

//#ifdef MY_FLAG
my logic
//endif

turned into

//#ifndef
/*
//#endif
mylogic
//#ifndef
*/
//#endif

so that the eclipse ignores the touch based code in 4.5 components.

now I have a question,

suppose I have a if-else block of preprocessor like this:

//#ifdef MY_FLAG
my logic for touch
//#elseif
my logic for qwerty
//endif

can I rewrite this stuff like this:

//#ifndef MY_FLAG
/*
//#endif
my logic for touch
//#ifndef
*/
//#endif

//#ifndef MY_FLAG
my logic for qwerty
//#endif

so that instead of 1 if-else block, there are 2 if b开发者_开发问答locks now. Will there be any performance issue due to this? Basically, are they the same?


The preprocessor statements are executed at compile time. It might take slightly longer to compile (and we're talking a really small amount of time) but there won't be any performance issues at runtime.


Do you actually have this working? Not did your 4.5 compile, but did your 4.7+ touch code compile and work? Eclipse actually creates a file (in /.preprocessed/ )that represents what it should do, but ignores the directives completely when compiling... in my case

I have been unable to get this working, using any of the variety of means posted around the net...

Shouldn't be this difficult, but hey, it's Blackberry ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜