How can I get a name of function running currently.

Y

Yeounkun, Oh

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.
 
R

Robert Gamble

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
 
S

Stuart Gerchick

Yeounkun said:
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.

Pre C-99 there is no standard way of doing this. __FUNCTION__ is an
addtion added by gcc. C99 you can use __func__
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top