concatenating __FUNCTION__

Kevin Nomura nomura@netapp.com
Thu Feb 21 09:33:00 GMT 2002


gcc 3.0 warns about concatenating __FUNCTION__ with a string
literal:

[tyrell]$ gcc-3.0.3/bin/gcc a.c
a.c: In function `main':
a.c:3: warning: concatenation of string literals with __FUNCTION__ is
deprecated.  This feature will
be removed in future
[tyrell]$ cat a.c
main()
{
        printf ("%s\n", __FUNCTION__ "hi");
}


I find this odd given that the manual explicitly calls out this
capability as a feature (section 5.41, "Function Names as Strings")
in contrast with __func__:

"This means that they catenate with other string literals,
and that they can be used to initialize char arrays".

I see no mention of deprecation.  Initializing a char array with 
__FUNCTION__ does not get a warning.

Is __FUNCTION__ itself deprecated?  (If not, why would the existing
ability to concatenate it be dropped?)  Thanks in advance for
clarification.

Kevin Nomura
Network Appliance



More information about the Gcc-help mailing list