Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DSDP - Mobile Tools for Java (MTJ) » Preprocessor question: defined value substitution
Preprocessor question: defined value substitution [message #576710] Wed, 26 August 2009 06:31 Go to next message
David Lucena is currently offline David Lucena
Messages: 74
Registered: August 2009
Member
Hi. I'm am trying to do something that I supposed that the preprocessor would do, but I am not sure if this behaviour is implemented.

I know the code would seem dumb, but is just for making the post short.


//#define ROWS = 10

int Rows = ROWS


It gives me errors because ROWS is not defined.


Regards.

David Lucena.
Re: Preprocessor question: defined value substitution [message #576721 is a reply to message #576710] Wed, 26 August 2009 06:56 Go to previous messageGo to next message
David Lucena is currently offline David Lucena
Messages: 74
Registered: August 2009
Member
Looking at the antenna preprocessor source code I have found something and I've tested it. Its something limited, but works.

You will define your symbol somewhere

//#define ROWS = 10

And to recover its value and assing it:

int Rows;
//#expand Rows = %ROWS%;

That has its limitations, as you cannot do things like:

CreateRows( #expand %ROWS% );

But instead you have to do:

int Rows;
//#expand Rows = %ROWS%;
CreateRows( #expand %ROWS% );


Anyone has gone deep in the preprocessor? Maybe I'll try the antenna documentation, now that I remember.
Re: Preprocessor question: defined value substitution [message #576791 is a reply to message #576721] Wed, 26 August 2009 08:31 Go to previous message
Diego Madruga Sandin is currently offline Diego Madruga Sandin
Messages: 116
Registered: July 2009
Senior Member
Quote:
> The preprocessor supports the following directives inside a Java source file. All directives follow a "//" comment that starts at the beginning of a line (whitespace is allowed left of them, but no Java code). That way, they don't interfere with normal Java compilation. Directives must not span multiple lines of code. In addition, whitespace is allowed between the // and the # of the directive to maintain preprocessor commands validity after eclipse source formatting.


From http://antenna.sourceforge.net/wtkpreprocess.php

I believe the correct to declare what you want is:

//#expand CreateRows( %ROWS% );
Previous Topic:CLDC 1.1 not recognized
Next Topic:Preprocessor question: defined value substitution
Goto Forum:
  


Current Time: Wed Aug 20 03:06:53 EDT 2014

Powered by FUDForum. Page generated in 0.02384 seconds