Re: gcc 3.3 and __func__ ...
On Thu, Oct 16, 2003 at 12:26:42PM -0400, Matt Zimmerman wrote:
> On Thu, Oct 16, 2003 at 05:59:43PM +0200, Sven Luther wrote:
>
> > I have some code that was using :
> >
> > printf (__func__ "Message", ...);
> >
> > This doesn't build anymore with gcc 3.x, since __func__ is treated as a
> > variable, not a string literal.
> >
> > What would be the best way of working around this ? Replacing all these
> > constructs with :
> >
> > printf ("%sMessage", __func__, ...);
> >
> > Works, but seems a bit ugly, and there are _lots_ of those lines.
> >
> > Is there a compiler switch to consider __func__ as string literal or
> > something such ?
>
> That behaviour is mandated by ISO C99, so even if it were possible to
> override it, the code needs to be fixed.
Yes, seemed so to me.
> The gcc-specific __FUNCTION__ and __PRETTY_FUNCTION__ are string literals,
Well, apparently no more in gcc 3.4.
> like what is expected here, except in C++, where they act like __func__.
> See "(gcc)Function Names". It'd really be best to adapt it to use __func__
> properly, since this is a standard which will be honored by other compilers.
What would be the best way to adapt it ? Use the
printf ("%sMessage", __func__, ...);
form ?
Thanks for your reply,
Friendly,
Sven Luther
Reply to: