Skip to content
Back to formatted view

Raw Message

Message-ID: <c2350ba40905231337u5ead6f97o95ee24f2faea081e@mail.gmail.com>
Date: 2009-05-23T20:37:14Z
From: Kynn Jones
Subject: Can a function know what other function called it?

Suppose function foo calls function bar.  Is there any way in which
bar can find out the name of the function that called it, "foo"?

There are two generalization to this question that interest me.
First, can this query go farther up the call stack?  I.e. if bar now
calls baz, can baz find out the name of the function that called the
function that called it, i.e. "foo"?  Second, what other information,
beside its name, can bar find about the environment where it was
called?  E.g. can it find out the file name and line number of the
function call?

Thanks!