lkml.org 
[lkml]   [2002]   [Jun]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] 2.5.21 kill warnings 4/19
On Mon, Jun 10, 2002 at 02:01:24PM -0700, Maksim (Max) Krasnyanskiy wrote:
>
> >> > wrt the __func__ thing: is it possible to do:
> >> >
> >> > #if (compiler version test)
> >> > #define __FUNCTION__ __func__
> >> > #endif
> >> >
> >> > to kill the 3.x warning?
> >>
> >> #include <stdio.h>
> >> #define __FUNCTION__ __func__
> >>
> >> int main(int argc, char **argv) {
> >> int i;
> >>
> >> for (i = 0; i < argc; i++) {
> >> printf(__FUNCTION__ " encountered argument ");
> >> printf("%s\n", argv[i]);
> >> }
> >>
> >> exit(0);
> >> }
> >>
> >> Obviously, yes.
> >
> >Nope.
> >$ gcc-3.1 -Wall -o foo foo.c
> >foo.c: In function `main':
> >foo.c:8: parse error before string constant
> >
> >And line 8 is:
> >printf(__FUNCTION__ " encountered argument ");
>
> Well, those will brake. But in general it's possible. And I already do that
> in Bluetooth code (it's been converted recently).
>
> So
>
> #if __GNUC__ <= 2 && __GNUC_MINOR__ < 95
> #define __func__ __FUNCTION__
> #endif
>
> does the trick. All gcc's newer than 2.95 support __func__.

Right. Maybe it should even go in <linux/compiler.h> if it's not
already there.

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:26    [from the cache]
©2003-2011 Jasper Spaans