Curious about libcxx __libcpp_nmstr design

I have couple of questions about __libcpp_nmstr class design.

It’s a reference counted char* class optimized for size, right?

Why is this so important to optimize this class size to the absolute minimum?

What is the purpose of the two unused_t? (I understand they are named unused…)
Why they are assigned the string length if never used?


libcxx/libcxxabi were created as replacements for gcc's-4.2 libstdc++. The intent is that all exception classes defined in <stdexcept> be ABI compatible with libstdc++-4.2 so that if an application found itself using both libc++ and libstdc++ (indirectly via various dylibs) that a std-defined exception propagated by one library could be caught by another, without worry about whether either library was linked against libstdc++ or libc++. In most recent work, the definitions for these types have migrated to libc++abi (, so that libc++abi can serve both libc++ and libstdc++, assuming libstdc++ has been ported to run on top of libc++abi.


Thanks, I see, it’s binary compatible with libstdc++ basic_string.

BTW, MingW libstdc++ standard DLL build statically links libsupc++ so it’s not replaceable. If libcxxabi.dll is also around, two copies of the ABI will exist linked at the same time to different parts of the programs.

I’m trying to build libcxx + libcxxabi combined.

On FreeBSD, we made libsupc++ and libcxxrt into shared libraries and then built libstdc++ as a filter library. It then links to either libsupc++ or libcxxrt and programs that use it will see the ABI library's symbols as if they had the same symbol version as the old ones in libstdc++.

This does require linking libstdc++ in a special way, but it doesn't require recompiling any code that links to libstdc++. I wonder if a similar solution would be possible for Windows?


You can have exactly the same configuration on Windows. I just built libcxx to use either libcxxabi or libsupc++, you could do the same with libstdc++. I’m trying to diagnose weird exception issues.

However with Windows 99% of the people will download a pre-compiled distribution from

and will not rebuild from sources as is common in FreeBSD or Linux.

Both these popular distributions provide libsupc++.a as a static library and libstdc++ linked against it so the abi is not easily replaceable.