Preprocessor parsing rules



Consider the following (weird) preprocessor code:

#define IDENT(x) x
#define ALPHA(x) BETA IDENT((x))
#define BETA(x) (x+2)

ALPHA(5)

Running this through Microsofts C preprocessor produces this result:

(5+2)

which is what I would expect. But if I run the same input through GCC's
preprocessor, I get

BETA (5)

which surprises me. (I'm using GCC version 3.4.4.)

Shouldn't the preprocessor rescan the line and replace the BETA macro?
Is this therefore a bug in GCC, or have I misunderstood something (in
which case Microsoft's compiler is doing something wrong)?

--
Claus Tondering

.



Relevant Pages