Bill Jonas on Tue, 24 Sep 2002 16:10:11 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] [C QUESTION] how to tell caller of a function


On Tue, Sep 24, 2002 at 09:49:20AM -0400, Kevin Brosius wrote:
> You can easily add printf() functions inside the code which print out
> the function name, or variables inside the program.

Well, yes, but the problem is how a function can get the name of the
function which is calling it so that you can print it in the first
place.

To go back to the original question, why not modify the function
slightly so that it takes an addtional char* argument and pass the name
of the caller when it calls the function?  Seems like the least work to
do what Fred's friend wants, unless there are dozens or hundreds of
instances of the function in question being called.

-- 
Bill Jonas    *    bill@billjonas.com    *    http://www.billjonas.com/
"They that can give up  essential  liberty to obtain a little temporary
safety deserve neither liberty nor safety."        -- Benjamin Franklin

Attachment: pgpcZtUuuMpU0.pgp
Description: PGP signature