Preprocessor parsing rules
- From: claus.tondering@xxxxxxxxx
- Date: 24 Mar 2006 06:57:56 -0800
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
.
- Follow-Ups:
- Re: Preprocessor parsing rules
- From: S.Tobias
- Re: Preprocessor parsing rules
- From: Robert Gamble
- Re: Preprocessor parsing rules
- Prev by Date: Re: How to know the size of array
- Next by Date: Re: Optional elements in a structure declaration? ( URGENT)
- Previous by thread: select () is hanging in AIX
- Next by thread: Re: Preprocessor parsing rules
- Index(es):
Relevant Pages
|