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 CCS Technical Support

defs.h

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







defs.h
PostPosted: Tue Jul 11, 2006 6:44 am     Reply with quote

When a register is in a #define instruction in header.h file, may I define the same register with another name in my program (with #define instruction) and use the two labels as I want?

Thank you
Ttelmah
Guest







PostPosted: Tue Jul 11, 2006 6:57 am     Reply with quote

Yes.
The '#define', is effectively a macro expansion. If you have:

#define fred (12345)

Then when the word 'fred' is seen in the code, '(12345)' is substituted. There is nothing at all to stop you having 'fred', and 'harry', both defining the same thing. You can even be 'evil', and have something defining another define, so:

#define harry fred
#define fred (12345)

Then if you type:

value=harry, value will be set to 12345.

However you must be very carefull about the _order_ of the declarations. They are executed 'as met', so as shown, 'harry' gets replaced with 'fred', and then 'fred' gets replaced with '(12345)'. However if the declarations are the other way round, 'harry' will be replaced with the text 'fred', and not the numeric value...

Best Wishes
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