Created
January 13, 2013 11:17
-
-
Save ermaker/4523603 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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