CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Macro prescan question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Marco P.
Guest







Macro prescan question
PostPosted: Fri Apr 04, 2008 1:54 pm     Reply with quote

I need to get a symbol containing the c source line number of its declaration.
Then I need to concatenate the __LINE__ result to another symbol.
For example I want to do

#define X ??????

so that where in the code appears

int X;

it becomes

int a12;

where 12 is the line numer of then "int X;" expression.

GNU preprocessor suggests to nest two macro calls in order to obtain the prescan and use its result in the second macro definition

Actually the following defines to the work into GNU C preprocessor

#define Z(l) a ## l
#define Y(l) Z(l)
#define X Y(__LINE__)

but in CCS the result is always a__LINE__ instead of a12.

Is this a bug or the desired behaviour? How can I solve my problem?

The final task is to use protothreads into CCS, but, due to the fact that CCS does not support the "case" statements put inside blocks nested into the switch block, I was trying to substitute the switch strategy using the goto_address and the label_address functions, but to do so, I need to define a label that contains the line number of its decalration.

Thank you.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group