Skip to content

Instantly share code, notes, and snippets.

@ermaker
Created January 13, 2013 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ermaker/4523603 to your computer and use it in GitHub Desktop.
Save ermaker/4523603 to your computer and use it in GitHub Desktop.
#include <typeinfo>
#include <cxxabi.h>
#include <cstdlib>
#include <iostream>
int example1()
{
return 0;
}
void example2(int a, char b, void* c, int (*d)())
{
}
int* example3(void* (*a)(int), const char* (*b)(int (*)(), char const*))
{
return NULL;
}
template<class T>
void print_funcname(T func)
{
char* str;
str = abi::__cxa_demangle(typeid(*func).name(), 0, 0, 0);
std::cout << str << std::endl;
free(str);
}
int main()
{
print_funcname(example1);
print_funcname(example2);
print_funcname(example3);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment