c - Pointer to current function -


Is there a way to get the pointer to the current function, maybe through the GCC extension or any other trick?

Edit I'm curious that it is possible to get function pointer without explicit use of the name of the function. I thought I had a good reason for this, I realized That I was not really, but if it is possible then still curious.

This is not particularly portable, Should work, where I can see the documentation; it certainly does not work on Windows which is a lack of API):

  #include & lt; Dlfcn.h & gt; // ... void * handle = dlopen (NULL, RTLD_LAZY); Zero * thisfunction = handle? Dlsym (handle, __FUNCTION__): null; If handles delclose (handle); // Remember to turn off!  

There are many other low-portable shortcuts that work on some platform but not others. It is not too fast; If you need speed, then cache it (i.e., in a local stable variable).


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -