UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C
  • » How to get the name of source code function() at run-time ?

#1 2003-12-22 08:59 AM

bzchevalier
Member
Registered: 2003-09-04
Posts: 40

Re: How to get the name of source code function() at run-time ?

void my_function (char *prefix)
{
fprintf(stderr,"[%s] Here we are in : %s",prefix,help_me(which_param));
}

Offline

#2 2003-12-22 02:47 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: How to get the name of source code function() at run-time ?

Use gcc's __FUNCTION__ or the standard C99 __func__

Example:

printf("Running function '%s' in file '%s', line %i", __func__, __FILE__, __LINE__);

Offline

#3 2003-12-24 12:59 PM

felix
Member
Registered: 2003-12-04
Posts: 171

Re: How to get the name of source code function() at run-time ?

printf("Running function '%s' in file '%s', line %i", __func__, __FILE__, __LINE__);

Offline

#4 2003-12-24 06:34 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: How to get the name of source code function() at run-time ?

Not that I know.. But if you want such info, then run the program in a debugger like GDB and put a breakpoint at your wrapper function (then you can run some command to get the callgraph or whatever, I've not much experience with debuggers yet).

Offline

#5 2003-12-26 01:24 PM

felix
Member
Registered: 2003-12-04
Posts: 171

Re: How to get the name of source code function() at run-time ?

Offline

  • Index
  • » C
  • » How to get the name of source code function() at run-time ?

Board footer

Powered by FluxBB