Why does code:
#define EXPONENT(num, exp) num ## e ## exp
EXPONENT(1,1)
EXPONENT(1,-1)
EXPONENT(1,+1)
after preprocessing changes into:
1e1
1e- 1
1e+ 1
and not into
1e1
1e-1
1e+1
? I suspect it might be because -1,+1 are parsed as two tokens (?). However, how in that case obtain the latter result?
You're right, -1
and +1
are two preprocessing tokens, hence only the first is pasted to the e
.
For me,
#define EXPO(num, sign, ex) num ## e ## sign ## ex
EXPO(1,,1)
EXPO(1,-,1)
EXPO(1,+,1)
worked with gcc-4.5.1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With