|
|
View previous topic :: View next topic |
Author |
Message |
guest Guest
|
defs.h |
Posted: Tue Jul 11, 2006 6:44 am |
|
|
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
|
|
Posted: Tue Jul 11, 2006 6:57 am |
|
|
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 |
|
|
|
|
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
|