2002-09-20 17:12:30

by Jeff Garzik

[permalink] [raw]
Subject: Re: FW: 2.5.34: IR __FUNCTION__ breakage

Jean Tourrilhes wrote:
> On Fri, Sep 13, 2002 at 08:25:50AM +0200, Dag Brattli wrote:
>
>>-----Original Message-----
>>From: Thunder from the hill [mailto:[email protected]]
>>Sent: 12. september 2002 22:17
>>To: Bob_Tracy
>>Cc: [email protected]; [email protected]
>>Subject: Re: 2.5.34: IR __FUNCTION__ breakage
>>
>>
>>Hi,
>>
>>On Thu, 12 Sep 2002, Bob_Tracy wrote:
>>
>>>define DERROR(dbg, args...) \
>>> {if(DEBUG_##dbg){\
>>> printk(KERN_INFO "irnet: %s(): ", __FUNCTION__);\
>>> printk(KERN_INFO args);}}
>>>
>>>which strikes me as not quite what the author intended, although it
>>>should work.
>>
>>Why not
>>
>>#define DERROR(dbg, fmt, args...) \
>> do { if (DEBUG_##dbg) \
>> printk(KERN_INFO "irnet: %s(): " fmt, __FUNCTION, args); \
>> } while(0)
>>
>>?
>>
>> Thunder
>
>
> Try it, it won't work when there is zero args.


I fixed up a bunch of these __FUNCTION__ breakage, you can grab them
from 2.5.37 (just released)

Also, specifically relating to varargs macros as described above, you
can certainly have a varargs macro with zero args, just look at C99
varargs macros...

Jeff




2002-09-20 17:13:58

by Jean Tourrilhes

[permalink] [raw]
Subject: Re: FW: 2.5.34: IR __FUNCTION__ breakage

On Fri, Sep 20, 2002 at 01:17:01PM -0400, Jeff Garzik wrote:
>
> I fixed up a bunch of these __FUNCTION__ breakage, you can grab them
> from 2.5.37 (just released)

I'll catch up with my e-mail and I'll look at that.

> Also, specifically relating to varargs macros as described above, you
> can certainly have a varargs macro with zero args, just look at C99
> varargs macros...

I remember that it didn't work. Ok, I'll try again.

> Jeff

Have fun...

Jean

2002-09-20 18:04:28

by Bjoern A. Zeeb

[permalink] [raw]
Subject: Re: FW: 2.5.34: IR __FUNCTION__ breakage

On Fri, 20 Sep 2002, Jean Tourrilhes wrote:

Hi,

> > Also, specifically relating to varargs macros as described above, you
> > can certainly have a varargs macro with zero args, just look at C99
> > varargs macros...
>
> I remember that it didn't work. Ok, I'll try again.

if I remember corretly with C99 if you do s.th. like this (simple
sample):

#define LOG(level, format, ...) \
log(level, format, ##__VA_ARGS__);

you _need_ to give an argument:

LOG(debug, "blah", 0);

w/o the ", 0" this is an error.

There have been gcc extentions that allow(ed) zero arguments.

*searching*

See: http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html

--
Bjoern A. Zeeb bzeeb at Zabbadoz dot NeT
56 69 73 69 74 http://www.zabbadoz.net/

2002-09-20 21:37:04

by Neil Booth

[permalink] [raw]
Subject: Re: FW: 2.5.34: IR __FUNCTION__ breakage

Bjoern A. Zeeb wrote:-

> > > Also, specifically relating to varargs macros as described above, you
> > > can certainly have a varargs macro with zero args, just look at C99
> > > varargs macros...
> >
> > I remember that it didn't work. Ok, I'll try again.
>
> if I remember corretly with C99 if you do s.th. like this (simple
> sample):
>
> #define LOG(level, format, ...) \
> log(level, format, ##__VA_ARGS__);

No, this is only valid C99 if __VA_ARGS__ is the empty list.

I posted the correct way to write this macro about a week ago that
works with all versions of GCC (and follows their documented
behaviour; this stuff *is* all documented).

Neil.

2002-09-20 22:06:04

by Jean Tourrilhes

[permalink] [raw]
Subject: Re: FW: 2.5.34: IR __FUNCTION__ breakage

On Fri, Sep 20, 2002 at 10:41:38PM +0100, Neil Booth wrote:
> Bjoern A. Zeeb wrote:-
>
> > > > Also, specifically relating to varargs macros as described above, you
> > > > can certainly have a varargs macro with zero args, just look at C99
> > > > varargs macros...
> > >
> > > I remember that it didn't work. Ok, I'll try again.
> >
> > if I remember corretly with C99 if you do s.th. like this (simple
> > sample):
> >
> > #define LOG(level, format, ...) \
> > log(level, format, ##__VA_ARGS__);
>
> No, this is only valid C99 if __VA_ARGS__ is the empty list.
>
> I posted the correct way to write this macro about a week ago that
> works with all versions of GCC (and follows their documented
> behaviour; this stuff *is* all documented).
>
> Neil.

Err... Can you point me to your post ?

Jean