RE: preprocessing question

2006-09-26 Thread Jan Beulich
#define xalt_x > >the preprocessor token "x" is an object-like macro standing for "alt_x", so >when we get to > #define alt_x(p) x(p+1) > > what the preprocessor sees after the first round of expansion is > >#define alt_x(p) alt_x(p+1) As pointed out before - there is *no* expan

Re: preprocessing question

2006-09-26 Thread Neil Booth
Jan Beulich wrote:- > Can anyone set me strait on why, in the following code fragment > > int x(unsigned); > > struct alt_x { > unsigned val; > }; > > #define xalt_x > #define alt_x(p) x(p+1) > > int test(struct x *p) { > return x(p->val); > } > > the function invoked in t

RE: preprocessing question

2006-09-26 Thread Dave Korn
On 26 September 2006 08:43, Jan Beulich wrote: Daniel Jacobowitz <[EMAIL PROTECTED]> 25.09.06 18:43 >>> >> On Mon, Sep 25, 2006 at 05:23:34PM +0200, Jan Beulich wrote: >>> Can anyone set me strait on why, in the following code fragment >>> >>> int x(unsigned); >>> >>> struct alt_x { >>>

Re: preprocessing question

2006-09-26 Thread Andreas Schwab
"Jan Beulich" <[EMAIL PROTECTED]> writes: > While, as Andreas also pointed out, the standard is a little vague in > some of what it tries to explain here, it is in my opinion clearly said > that the re-scanning restrictions are bound to the macro name, not > the fact that a function-like macro's e

Re: preprocessing question

2006-09-26 Thread Jan Beulich
>>> Daniel Jacobowitz <[EMAIL PROTECTED]> 25.09.06 18:43 >>> >On Mon, Sep 25, 2006 at 05:23:34PM +0200, Jan Beulich wrote: >> Can anyone set me strait on why, in the following code fragment >> >> int x(unsigned); >> >> struct alt_x { >> unsigned val; >> }; >> >> #define xalt_x >> #d

Re: preprocessing question

2006-09-25 Thread Andreas Schwab
Daniel Jacobowitz <[EMAIL PROTECTED]> writes: > On Mon, Sep 25, 2006 at 05:23:34PM +0200, Jan Beulich wrote: >> Can anyone set me strait on why, in the following code fragment >> >> int x(unsigned); >> >> struct alt_x { >> unsigned val; >> }; >> >> #define xalt_x >> #define alt_x(p

Re: preprocessing question

2006-09-25 Thread Daniel Jacobowitz
On Mon, Sep 25, 2006 at 05:23:34PM +0200, Jan Beulich wrote: > Can anyone set me strait on why, in the following code fragment > > int x(unsigned); > > struct alt_x { > unsigned val; > }; > > #define xalt_x > #define alt_x(p) x(p+1) > > int test(struct x *p) { > return x(p->

Re: preprocessing question

2006-09-25 Thread Michael Gong
Yes. You are right. - Original Message - From: "Andreas Schwab" <[EMAIL PROTECTED]> To: "Michael Gong" <[EMAIL PROTECTED]> Cc: "Jan Beulich" <[EMAIL PROTECTED]>; Sent: Monday, September 25, 2006 12:08 PM Subject: Re: preprocessing quest

Re: preprocessing question

2006-09-25 Thread Manuel López-Ibáñez
The output with cpp 4.0.3: int test(struct alt_x *p) { return alt_x(p->val+1); } It seems that: 1) "x" expands to alt_x 2) "alt_x(p->val)" expands to "x(p->val+1)" 3) "x" expands (again!) to alt_x or maybe something else?

Re: preprocessing question

2006-09-25 Thread Andreas Schwab
"Michael Gong" <[EMAIL PROTECTED]> writes: > One explanation could be: > > - Original Message - > From: "Jan Beulich" <[EMAIL PROTECTED]> > To: > Sent: Monday, September 25, 2006 11:23 AM > Subject: preprocessing question > > >> Can anyone set me strait on why, in the following code frag

Re: preprocessing question

2006-09-25 Thread Michael Gong
One explanation could be: - Original Message - From: "Jan Beulich" <[EMAIL PROTECTED]> To: Sent: Monday, September 25, 2006 11:23 AM Subject: preprocessing question Can anyone set me strait on why, in the following code fragment int x(unsigned); struct alt_x { unsigned val; }; #d