Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crossplatform naming? #21

Open
lp35 opened this issue Jan 18, 2018 · 4 comments
Open

Crossplatform naming? #21

lp35 opened this issue Jan 18, 2018 · 4 comments

Comments

@lp35
Copy link

lp35 commented Jan 18, 2018

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,

@lp35 lp35 changed the title Crossplateform naming? Crossplatform naming? Jan 18, 2018
@Manu343726
Copy link
Owner

Manu343726 commented Jan 18, 2018

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

@lp35
Copy link
Author

lp35 commented Jan 19, 2018

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?

@Manu343726
Copy link
Owner

Manu343726 commented Jan 19, 2018

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)

@revel8n
Copy link

revel8n commented Dec 1, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants