2002-09-03 20:48:03

by Rasmus Andersen

[permalink] [raw]
Subject: __func__ in 2.5.33?

Hi,

I trying to compile the SX driver for the 2.5.33 kernel, I got a
lot of warnings looking like (this is from a test program, not
the driver itself)

test.c: In function `main':
test.c:6: called object is not a function
test.c:6: parse error before string constant

This seems to stem from the recent __FUNCTION__ vs. __func__
change in kernel.h and the SX driver's use of __FUNCTION__ in the
following construct

#define func_enter() sx_dprintk (SX_DEBUG_FLOW, "sx: enter " __FUNCTION__ "\n")

My gcc (vers. 2.96) does not accept the above when __FUNCTION__ is
#defined to be (__func__). I likes __func__ well enough, though.

So I guess my question is whether I should change the above define,
and if so, to what, or if __FUNCTION__ should be defined to something
else?

BTW, it was my impression that the kernel would continue
with __FUNCTION__? Maybe I missed something....

Regards,
Rasmus


Attachments:
(No filename) (900.00 B)
(No filename) (232.00 B)
Download all attachments

2002-09-03 21:46:25

by Andrew Morton

[permalink] [raw]
Subject: Re: __func__ in 2.5.33?

Rasmus Andersen wrote:
>
> Hi,
>
> I trying to compile the SX driver for the 2.5.33 kernel, I got a
> lot of warnings looking like (this is from a test program, not
> the driver itself)
>
> test.c: In function `main':
> test.c:6: called object is not a function
> test.c:6: parse error before string constant
>
> This seems to stem from the recent __FUNCTION__ vs. __func__
> change in kernel.h and the SX driver's use of __FUNCTION__ in the
> following construct
>
> #define func_enter() sx_dprintk (SX_DEBUG_FLOW, "sx: enter " __FUNCTION__ "\n")
>

The parenthesised (__func__) is there to force you to not try to
perform this string pasting. Support for __FUNCTION__ pasting is
being phased out of gcc.

You need:

#define func_enter() sx_dprintk (SX_DEBUG_FLOW, "sx: enter %s\n", __FUNCTION__)

2002-09-03 22:10:35

by Paul Larson

[permalink] [raw]
Subject: Re: __func__ in 2.5.33?

I posted this a few days ago, but I don't think it's been picked up yet.

-Paul Larson


Attachments:
(No filename) (1.72 kB)
Forwarded message - [TRIVIAL][PATCH] fix __FUNCTION__ pasting in sx.c

2002-09-04 06:30:10

by Rasmus Andersen

[permalink] [raw]
Subject: Re: __func__ in 2.5.33?

On Tue, Sep 03, 2002 at 02:48:40PM -0700, Andrew Morton wrote:
> The parenthesised (__func__) is there to force you to not try to
> perform this string pasting. Support for __FUNCTION__ pasting is
> being phased out of gcc.
>
> You need:
>
> #define func_enter() sx_dprintk (SX_DEBUG_FLOW, "sx: enter %s\n", __FUNCTION__)

Ah, OK. I apparently missed the part about the pasting part
being phased out, alongside missing Paul Larson's patch.

Thanks to both of you,
Rasmus


Attachments:
(No filename) (476.00 B)
(No filename) (232.00 B)
Download all attachments