Re: Question about C Programming.

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

 



Actually there is one pretty common method to achieve this. Just define a macro
#define bar() debug_bar(__func__)
and then write a small function debug_bar(char *funct_name) which will use this string as you want and will call original bar() function.

-Vinit

On Thu, Mar 5, 2009 at 12:49 PM, Ravi Sankar <ravisankar.g@xxxxxxxxx> wrote:
Hi,

I would like to know how can I get the function name of the caller in c?.

Like
// c code

void foo(void)
{

bar();
}

void bar(void)
{
  // who is my caller?
}

I don't want to change the caller function code to add arguments etc.   Even  I don't have access to the caller function source code.

Thanks for your help.

--
--,
BR,
Ravi Sankar Guntur.


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux