Path: utzoo!utgpu!news-server.csri.toronto.edu!me!writer Newsgroups: comp.lang.c From: writer@me.utoronto.ca (Tim Writer) Subject: How do I get the address of the current function? Message-ID: <90Jun28.195353edt.19442@me.utoronto.ca> Organization: University of Toronto, Department of Mechanical Engineering Date: 28 Jun 90 23:54:03 GMT This is a question that has puzzled me for some time. It may be more appropriate in comp.unix.wizards but I thought I'd try my luck here first. Is there a way to get the address of the function which is currently executing? For example: char *fcn; void foo() { ... fcn=current_function(); ... do something with fcn } You may ask why? Or why not just "fcn=(char *) foo"? I am using setjmp() and longjmp() to do some error handling. When I use longjmp() it may jump out of the current function or it may not. Sometimes I want to jump back to where I used longjmp(). I do this with another setjmp(), longjmp() pair. However, I can only do the second longjmp() if the first remained within the current function. In short, I am trying to discern if a longjmp() would jump into a function that has already returned. I thought that a function like current_function() would be helpful. On some systems, if longjmp() encounters a problem, it calls a user definable function, longjmperror(). Mine doesn't. If someone has a solution to this longjmp() problem which doesn't involve something like current_function(), I'd be happy to hear from you. But, I'd still like to know if it is possible to do something like current_function(). Thanks in advance. Tim P.S I'm using a sparcStation running Sun 4.0.