Warning with macro token pasting operator (##)

09 Dec 2011

Hi, I get the following warning: "concatenation with "p5_SEL_MASK" in macro "AS_OUT" does not create a valid token" in file ..., Line: 17, Col: 4

when compiling the following code:

/* p5 is P0.9 */
#define p5_SEL_MASK     ~(3UL << 18)
#define p5_SET_MASK     (1UL << 9)

#define AS_OUTPUT(pin) LPC_PINCON->PINSEL0&=##pin##_SEL_MASK; LPC_GPIO0->FIODIR|=##pin##_SET_MASK

AS_OUTPUT(p5);

But I don't see a problem here. Any suggestions or should I ignore this warning? Regards, René

10 Dec 2011

I don't think you need the concatenation operator before the "pin" keyword. I think you just want to end up pasting p5 with _SEL_MASK and _SET_MASK.

#define AS_OUTPUT(pin) LPC_PINCON->PINSEL0&=pin##_SEL_MASK; LPC_GPIO0->FIODIR|=pin##_SET_MASK
10 Dec 2011

right, just copied from visual studio editor where no warning was generated.