codecvt<char, char, mbstate_t>::id
Eldridge Mount
emount@intrinsix.com
Thu Aug 23 08:29:00 GMT 2001
Hello,
I ran across several posts regarding a link error with libstdc++.so.3.0.0
that I have had as well. I'm distributing a reusable C++ library across our
company and to several customers that is built with GCC, and several of them
had this issue. I've found the source of the problem, and figured I'd share
it with you, since it's kind of an obscure one. First, configure has been
notoriously bad at determining which headers and functions I have on my
system, a Sun sparc running Solaris 2.7. I invariably have to run
configure, then make, and wait for it fail. The source isn't told to
include standard files like unistd.h, sys/types.h, and the like. So... I've
gotten pretty comfortable mucking around in the config.h files for
libstdc++-v3:
build/sparc-sun-solaris2.7/libstdc++-v3/config.h, and
build/sparc-sun-solaris2.7/libstdc++-v3/include/c++config.h.
The issue stems from the use (or non-use) of the mbstate_t type in wchar.h.
On Solaris, anyways, there is an implementation-specific type named
__mbstate_t; this type is used as the third template parameter for codecvt
classes, and indicates to the instantiated class that it is a converter for
internally-defined character types (char, and wchar_t). After running
configure on my machine, the macros:
HAVE_MBSTATE_T (from libstdc++-v3/config.h) and
_GLIBCPP_HAVE_MBSTATE_T (from libstdc++-v3/include/bits/c++config.h)
are *not* defined. As a result, the file
src/gcc-3.0/libstdc++-v3/include/c_std/bits/std_cwchar.h defines the
mbstate_t type directly. If I correct the configure script, the definition
in wchar.h is used; which is:
typedef __mbstate_t mbstate_t;
So... if I tell the build to use the mbstate_t defined in wchar.h, the
symbols generated have the signature:
std::codecvt<char, char, __mbstate_t>
since the typedef substitutes the actual type in the code. If I let GCC
define mbstate_t, I get these signatures:
std::codecvt<char, char, mbstate_t>
This is a bit of a pain, and seems to be affecting a lot of people. I don't
know what, if any, portable fix there is... obviously, on solaris and other
similarly affected systems, changing this definition in std_cwchar.h:
#ifndef _GLIBCPP_HAVE_MBSTATE_T
extern "C"
{
typedef struct
{
int __fill[6];
} mbstate_t;
}
#endif
to
#ifndef _GLIBCPP_HAVE_MBSTATE_T
extern "C"
{
typedef struct
{
int __fill[6];
} __mbstate_t;
}
typedef __mbstate_t mbstate_t;
#endif
would do the trick, but I don't know if this would jive with other targets.
Hope this at least gets you pointed in the right direction...
- Eldridge
More information about the Gcc-bugs
mailing list