On Fri, Sep 14, 2012 at 9:10 AM, Georg-Johann Lay <avr@xxxxxxxx> wrote: > Hi, consider the following C code that tries to compose literals that use > gcc's P extension: > > #define VAL1(X, SUFFIX) \ > X##SUFFIX > > int x1 = VAL1 (0x123, P-2u); > > #define VAL2(X, SUFFIX) \ > X##P-2##SUFFIX > > int x2 = VAL2 (0x123, u); > > Compiling this runs into "error: exponent has no digits" error because > cpp introduces a bad blank before the minus (same with +). > > cpp expands the code to (with -P -g3): > > #define VAL1(X,SUFFIX) X ##SUFFIX > int x1 = 0x123P -2u; > #define VAL2(X,SUFFIX) X ##P-2 ##SUFFIX > int x2 = 0x123P -2u; > > Is this a bug or a feature? Feature, try this: #define VAL2_(X, SUFFIX) \ X##-##SUFFIX #define VAL2(X, SUFFIX) \ VAL2_(X##P, 2##SUFFIX) Bert