diff --git a/simgear/structure/intern.hxx b/simgear/structure/intern.hxx index 5a1c0e47..3d3e1ef9 100644 --- a/simgear/structure/intern.hxx +++ b/simgear/structure/intern.hxx @@ -3,12 +3,33 @@ #include +#include +#if __linux__ +#include +#endif + namespace simgear { + +/* return the template name as a string */ +template +std::string getTypeName(void) +{ +#ifdef _WIN32 + std::string name = typeid(T).name(); +#else // __linux__ + int error = 0; + char *type = abi::__cxa_demangle(typeid(T).name(), 0, 0, &error); + std::string name = type; + free(type); +#endif + + return name; +} + /** * Return a pointer to a single string object for a given string. */ - const std::string* intern(const std::string& str); } #endif