Igor Liferenko Igor Liferenko - 1 month ago 27
C Question

What is "compatibility for C++ mangling"?

type is set inside
, using the fact that
is already defined in the compiler by default. So to change

typedef unsigned int wint_t;


typedef wchar_t wint_t;

we may use the following code in the beginning of

#undef __WINT_TYPE__
#define __WINT_TYPE__ wchar_t
#define WEOF (-1)

But this comment suggests that doing this "breaks compatibility for C++ mangling".

You can't change existing definitions of typedefs such as wint_t without breaking ABI compatibility (even when you have the same size and
signedness and so are ABI-compatible for C, changing the underlying type
breaks compatibility for C++ mangling).

So, why exactly this typedef cannot be changed and what is "compatibility for C++ mangling"?

See also this question How to change wchar.h to make wchar_t the same type as wint_t?


So here's some relevant definitions:

Name mangling is the way that the compile represents the method-names you define in C++ so that they're qualified "per class" so for instance ClassA::method() doesn't clash with ClassB::method() - this also facilitates overloading such that ClassA::method(String s) doesn't clash with ClassA::method(int i).

Internally these might be represented something like ClassA_method, ClassA_method^String, ClassA_method^int

As the second topic above discusses "name mangling is not merely a compiler-internal matter" - in cases where a public interface for a shared library is being generated, for instance.

So if you take a typedef and change it for your own code, it'll be okay for all the binaries you generate, but any pre-existing binaries such as 3rd party DLLs that depend on this typedef will break.