How do I get the address of the current function?

Peter Wentworth cspw at quagga.uucp
Tue Jul 3 21:38:53 AEST 1990


I solved a similar problem by using a macro expansion to generate
the function headings:  in my case all the routines had the same
prototypes, and I was generating the C code automatically from 
another compiler.  As part of the macro expansion you can
'undef' a compile time name, say CURR_FN, and redefine it.

The expanded code for every function looked something like this

#undef CURR_FN
#define CURR_FN   f
void f(...)
{
    use the address of CURR_FN as    &CURR_FN
}  

This is a horrible work-around, but it worked nicely for cases when
I was generating the function bodies automatically.  I don't believe
there is any way to directly reference the current function without
using its name.

Pete 
-- 
EP Wentworth - Dept. of Computer Science - Rhodes University - Grahamstown.
Internet: cspw.quagga at f4.n494.z5.fidonet.org          
Uninet: cspw at quagga      
uucp: ..uunet!m2xenix!quagga!cspw         



More information about the Comp.lang.c mailing list