Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!sdd.hp.com!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!tkou02.enet.dec.com!diamond From: diamond@tkou02.enet.dec.com (diamond@tkovoa) Newsgroups: comp.lang.c Subject: Re: How do I get the address of the current function? Message-ID: <1823@tkou02.enet.dec.com> Date: 29 Jun 90 02:50:19 GMT References: <90Jun28.195353edt.19442@me.utoronto.ca> Reply-To: diamond@tkou02.enet.dec.com (diamond@tkovoa) Organization: Digital Equipment Corporation Japan , Tokyo Lines: 22 In article <90Jun28.195353edt.19442@me.utoronto.ca> writer@me.utoronto.ca (Tim Writer) writes: >Is there a way to get the address of the function which is currently >executing? If you know the name of the function, if it is foo, you just say &foo >char *fcn; >void foo() { > fcn=current_function(); >} Your compiler might or might not let you convert a function pointer to a char pointer. If it lets you, the result might or might not be usable. And if you can convert back, it might again be unusable. Safer is: void (*fcn)(); void foo() { fcn = &foo; } -- Norman Diamond, Nihon DEC diamond@tkou02.enet.dec.com This is me speaking. If you want to hear the company speak, you need DECtalk.