This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c_str on a wstring tries to return a char*
- To: gcc-bugs at gcc dot gnu dot org
- Subject: c_str on a wstring tries to return a char*
- From: Aaron Hope <edh at brioforge dot com>
- Date: Tue, 17 Oct 2000 10:43:23 -0400
- Reply-To: edh at mail dot brioforge dot com
I'm having some trouble getting a null-terminated wide character array out of a
wstring to pass to wcstombs(). It seems that the 2.10 and cvs versions of
bastring.h in libstdc++ (not listdc++-v3) return a pointer to a string literal from
c_str(). So I get:
/usr/lib/gcc-lib/i386-linux/2.95.2/../../../../include/g++-3/std/bastring.h:335:
initialization to `const __wchar_t *' from `const char *
Seems like the appropriate fix would be to return a pointer to a global (ick),
a static member (yucky init), or a member (a. la data()). BTW, what's wrong
with always returning data()? It looks like that's what libstdc++-v3 does.
Thanks, Aaron Hope