Skip to contentSkip to conversation

2.5.34: IR __FUNCTION__ breakage

DISCUSSION Jean Tourrilhes 5 participants 7 messages Sep 20, 2002 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 21 lines · Dag Brattli

-----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,

Quoted 7 lines · Bob_Tracy
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

Quoted 8 lines
#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.

Jean

#2 lore raw
Quoted 29 lines · Jean Tourrilhes
Quoted 27 lines · Dag Brattli

-----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,

Quoted 7 lines · Bob_Tracy
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)
Quoted 6 lines
Quoted 3 lines

?

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

#3 lore raw
Quoted 3 lines · Jeff Garzik

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.

Quoted 3 lines

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.

Quoted 1 line

Jeff

	Have fun...

	Jean
#4 lore raw

On Fri, 20 Sep 2002, Jean Tourrilhes wrote:

Hi,

Quoted 5 lines
Quoted 3 lines

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

Signature · 2 lines
Bjoern A. Zeeb				bzeeb at Zabbadoz dot NeT
56 69 73 69 74				http://www.zabbadoz.net/
#5 lore raw

Bjoern A. Zeeb wrote:-

Quoted 11 lines
Quoted 5 lines
Quoted 3 lines

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.

#6 lore raw
Quoted 14 lines · Neil Booth

Bjoern A. Zeeb wrote:-

Quoted 11 lines
Quoted 5 lines
Quoted 3 lines

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__);
Quoted 7 lines

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

#7 lore raw
In reply to Jean Tourrilhes

Hi,

Quoted 7 lines · Jean Tourrilhes
Quoted 7 lines

Why not

#define DERROR(dbg, fmt, args...) \
	do { if (DEBUG_##dbg) \
		printk(KERN_INFO "irnet: %s(): " fmt, __FUNCTION, args); \
	} while(0)
Quoted 5 lines
Quoted 3 lines

?

Thunder

Try it, it won't work when there is zero args.

It got corrected shortly afterwards. The non-typo version is:

#define DERROR(dbg, fmt, args...) \
	do { if(DEBUG_##dbg) \
		printk(KERN_INFO "irnet: %s(): " fmt, __FUNCTION__, ##args); \
	} while(0)

Example:

#define DEBUG(fmt, args...) \
        printf("%s(): " fmt, __FUNCTION__, ## args)

int main(void)

{
        DEBUG("I am hungry.\n");

        exit(0);
}
# gcc -Wall -Os -o moehre -s moehre.c
# ./moehre
main(): I am hungry.
# 

Thunder

Signature · 1 line
assert(typeof((fool)->next) == typeof(fool));	/* wrong */