Hello:

I wonder what do you think about a patch to implement getting a pointer to the current function. Is it a "no, under no circumstances"? Or it is a "maybe, show us the code"?

I'll explain better what I mean: currently there is the statement __func__ that returns a string with the name of the current function. This allows to print (for example from a macro) which is the current function name. Along with __LINE__ it is useful for debugging, among other things.

But I miss an statement that allows to have a pointer to the current function. Thus putting it in a macro would allow to have a pointer to the function where that macro is. It would be very useful for coroutines, for example. I've been searching and can't find a simple way of doing it. Some people proposes to use __func__ combined with dlsym and dlopen, but it is slow and clearly a hack, and forces to use -rdynamic, which is not always possible/desirable. Currently I use another macro to define the function itself, passing the desired name as an argument and creating a variable with a pointer to it, but it is ugly.

Thanks.

--
Nos leemos
                         RASTER    (Linux user #228804)
rasters...@gmail.com                https://www.rastersoft.com

Reply via email to