On 4 Oct 2014 at 14:42, Mathias Gaunard wrote:
On 04/10/2014 13:24, Niall Douglas wrote:
Andrey, please list here three C++ compilers which had at least one version release in the past five years which doesn't provide a magic macro expanding out to the mangling of the enclosing function.
What about MinGW?
I just ran the following program on MinGW: #include <iostream> #include <typeinfo> template<class T> void doprint(T a) { std::cout << __func__ << std::endl; std::cout << __FUNCTION__ << std::endl; std::cout << __PRETTY_FUNCTION__ << std::endl; struct $$$ { }; std::cout << typeid($$$).name() << std::endl; } template<class T> struct doprint$$$___$$$ { }; int main(void) { doprint(1); std::cout << typeid(doprint$$$___$$$<int>).name() << std::endl; return 0; } It prints: doprint doprint void doprint(T) [with T = int] Z7doprintIiEvT_E3$$$ 16doprint$$$___$$$IiE Something I was wrong about is that there is no equivalent to __FUNCDSIG__ in GCC - I had thought that __FUNCTION__ produced mangled symbols, and I was wrong on that - I can find no magic macro for GCC which can. You can however still fall back onto typeid, albeit this forces a dependency on RTTI. I suppose one could just parse one's own ELF binary headers to look up mangled symbols you yourself instantiated, but that is getting a bit extreme. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/