Crossplatform naming?
lp35 opened this issue · 4 comments
Hi,
Thank you for this piece of code, really instructive.
I'm working on a serialization system that works across platforms. I'm wondering if you have any idea of how the ctti::nameof() can produce the same result on MSVC15 and GCC for instance.
Have a nice day, thanks,
The main issue is that msvc prepends class/struct prefixes into the mangled type name, which results in the pretty function string having a struct/class prefix. The solution would be to parse and filter those at compile time. I already worked on something in that regard, see detail/name_filters.hpp, but I have to apply some fixes first to have the library working on msvc (some metaprogramming parts of the lib are not compatible with the way msvc does C++ ...).
My end goal is to have cross platform type IDs. Another issue are the inline namespaces that most STL implementations use for versioning. For example, iirc libcxx (llvm) exports std stuff as "std::__1::". Since this is not just a prefix but a substring, I need to implement fixed size templated strings first in order to get and concatenate substrings (i.e. to filter that "__1" substring from the type name).
For your reference, here's the function implementing the msvc class prefix filter https://github.com/Manu343726/ctti/blob/master/include/ctti/detail/name_filters.hpp#L32
Please note that your project is not compiling on my Visual Studio 2015, compiler is throwing a compiler "crash" error. I think it's due to MSVC memory limitation at compile time. Have you ever experienced this?
Maybe I should update the compiler status, iirc last time I checked VS compatibility was one year ago. Nothing prevents the lib from working on VS, it's just that a did a bit rework of the internals (I'm working on fixes)
was this ever addressed?
https://github.com/bkietz/wnaabi
i had been planning on looking into how the library above handled this in order to integrate it into this project, so was curious how your approach compares in this regard, in addition to the similar issue with regard to anonymous namespaces, etc. that are also complicated by compiler differences.