On Tue, 16 Nov 2004 11:15:43 +0900, Yeounkun, Oh wrote:
Hello,
I want to know the name of function() in program. In "gcc", I know that
__FUNCTION__ macro is used for getting that. but in "cc", __FUNCTION__
macro does not exist. I can't find function to get the name of function
running currently. Could anybody help me?
Thanks.
ps. OS is SunOS 5.8
Regards.
__FUNCTION__ is a gcc extension. C99 defines __func__ as a "predefined
identifier" which will evaluate to a variable of type char[] (or static
const char[] to be precise) containing the name of the function in which
it is evaluated. There is no C89 equivalent but most compilers that
support any of the C99 standard support __func__ and many others have a
similiar extension. You don't have to do anything special to make this
functionality available (outside setting your compiler to c99 mode if
applicable).
<OT>
gcc considers __FUNCTION__ to be deprecated and newer versions treat it
the same as __func__ (there are some minor differences between the two),
you should avoid using the gcc extension for portability reasons. </OT>
Rob Gamble