Macro Substitution Problem

I just wanted to share a problem on macro substitution.

Following link gives a clear information on the problem as well as the
solution,
http://c-faq.com/ansi/stringize.html
My issue was with the use of token pasting operator.
I had a similar problem where in, instead of the ‘value’ the ‘macro’ itself
was getting placed.
__REGISTER_SET(__TMR_VREG_VALUE_REGISTER(TMR_ID_2), Value)

Actually it should have been expanded as – (*((&TMR2)) = 0x12345678)

[VREG implemented as TMR##i]
But it is getting expanded as – (*((&TMRTMR_ID_2)) = 0x12345678)

It was possible to get rid of this problem by incorporating one more level of
indirection.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s