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.

The gcc-specific __FUNCTION__ and __PRETTY_FUNCTION__ are string literals,
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.

-- 
 - mdz


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to