This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [BUG] gcc-3.4.5-20050531 (i386): __FUNCTION__ as a part of the printf's format argument
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: gcc at gcc dot gnu dot org, zzz at anda dot ru
- Date: Mon, 25 Jul 2005 10:51:23 +0200
- Subject: Re: [BUG] gcc-3.4.5-20050531 (i386): __FUNCTION__ as a part of the printf's format argument
- References: <20050725144132.A18786@ward.six>
- Reply-to: Richard Guenther <richard dot guenther at gmail dot com>
On 7/25/05, Denis Zaitsev <zzz@anda.ru> wrote:
> Such an example can't be compiled:
>
>
> #include <stdio.h>
>
> void x()
> {
> printf(__FUNCTION__ "\n");
> }
>
>
> $ gcc printf.c -o fprintf
> printf.c: In function `x':
> printf.c:5: error: syntax error before string constant
__FUNCTION__ expands to a variable. Use
printf("%s\n", __FUNCTION__);
instead. Btw, this list is for the development _of_ gcc, not with gcc.
Use gcc-help for that.
Richard.
>
> Then, the problem is not printf-specific and is not depend of
> <stdio.h>. The next example gives the same error:
>
>
> void y(const char *f, ...);
> void z()
> {
> y(__FUNCTION__ "\n");
> }
>
>
> If some args are present in the ellipsis section (i.e. y(__FUNCTION__
> ": %s\n", "xxx")), the problem doesn't vanish. And, if __FILE__ is
> used instead of __FUNCTION__, the problem is absent.
>