On Monday 28 April 2014 06:03:16 Rob Stewart wrote:
On April 28, 2014 5:54:41 AM EDT, Andrey Semashev
wrote: On Monday 28 April 2014 05:48:42 Rob Stewart wrote:
On April 27, 2014 1:47:22 PM EDT, Andrey Semashev
wrote: On Sunday 27 April 2014 13:02:41 Rob Stewart wrote:
On April 27, 2014 10:43:27 AM EDT, Andrey Semashev
wrote: On Friday 25 April 2014 09:25:45 Dominique Devienne wrote: > But what bothered me a little was the note about the fact that > pretty_name() was not consistent across platforms/compilers.
There is generally no way to obtain a portable type name. Each
compiler
and platform has its own mangling rules and there are no rules for
the
demangled type names whatsoever.
The language standard specifies rules for the demangled names,
does
it not?
No. The type_info::name() method returns some implementation-defined string with no guarantees on its format. __func__ also has unspecified
format.
To my knowledge, there are no other sources of type name strings in the language.
I wasn't clear. I meant that the language grammar specifies the
syntax of
the demangled names, though it permits lots of whitespace variation.
The problem is that those strings are not required to follow that syntax. And they don't in some cases.
If they have the required information, however it may be encoded, all that's needed is to resemble it. Is that out of scope?
As I said, the format of the strings is not defined. You may be able to reconstruct something resembling a C++ type declaration or you may not. In some cases there simply isn't a C++ syntax to represent a type name (e.g. types with anonymous namespaces). The only way to deal with it is to support every particular compiler out there and hope it provides enough information in the strings. A task I called not feasible and not particularly useful.