[comp.lang.c] preprocessor constant which names the current function

daveh@marob.masa.com (Dave Hammond) (02/09/90)

I am constructing an error notification routine which outputs an error
code, the name of the C function which called the error routine, and an
error message.

The current interface requires the programmer to name the function, ie:

	Error(int errcode, char *function_name, ...)

It would save coding time (and make the interface simpler) if C provided
a compile-time method for determining the current function name.

Given that the C preprocessor definitions __FILE__ and __LINE__ specify
the current source module and line, is there an analagous definition for
the current source function (eg __FUNCTION__) ?

--
Dave Hammond
daveh@marob.masa.com
daveh@dsix2.uucp

henry@utzoo.uucp (Henry Spencer) (02/10/90)

In article <25D1A098.493B@marob.masa.com> daveh@marob.masa.com (Dave Hammond) writes:
>Given that the C preprocessor definitions __FILE__ and __LINE__ specify
>the current source module and line, is there an analagous definition for
>the current source function (eg __FUNCTION__) ?

No.  Not unless it's a non-standard extension in the only compiler you
ever plan to use.
-- 
SVR4:  every feature you ever |     Henry Spencer at U of Toronto Zoology
wanted, and plenty you didn't.| uunet!attcan!utzoo!henry henry@zoo.toronto.edu