maadhuu said:
hi, i still have a doubt . i know that "#" is the stringinizing operator
and "##" is the concatenation operator........now, if the inner operation
is performed first as in, in the 1st case f(1,2) and in the 2nd case also,
f(1,2) and then the outer operation, don't you think that the output should
be the same .........i want to know how does one extra layer in case of
h(f(1,2)) make the difference ........thanking you, coz' it seemed to me
that both h(f(1,2)) and g(f(1,2)) should give the same output.
Please provide _context_!
Without it, you make it unnecessarily hard for other people to help you.
Your original message contained
,----
|#include <stdio.h>
| #define f(a,b) a##b
| #define g(a) #a
| #define h(a) g(a)
|
| int main()
| {
| printf("%s\n",h(f(1,2)));
| printf("%s\n",g(f(1,2)));
| return 0;
| }
`----
The "extra layer" makes all the difference because preprocessor
operation is essentially text replacement:
g(f(1,2)) becomes #f(1,2) because this is how the # operator works.
h(f(1,2)) becomes g("Expand(f(1,2))") i.e. g(12) because this is
how macro treatment in the absence of # works.
So, the additional "layer" leads to actual expansion of f(1,2).
Cheers
Michael