This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: C++ demangler horrors
On Fri, Jun 27, 2003 at 05:13:00PM -0400, Phil Edwards wrote:
> Someone has volunteered to write or submit miniature versions of string
> and vector, but I haven't heard whether he also plans to maintain those.
I wrote them.
> This is turning into a mess.
Thats what I thought, so I stopped paying attention ;).
Just waiting till things settle down.
I lost track of what is the problem - seems all politics to me.
Last thing I knew is that I wrote a small C library that can
be produced using the exact same demangle.h that will be part
of libstdc++ (thus: a single code base maintained by me).
~/c++/demangle_lib2>cat test_dem.c
#include <stddef.h>
#include <stdio.h>
char* __cxa_demangle(const char*, char*, size_t*, int*);
int main()
{
int status = 0;
const char* p;
p = __cxa_demangle("_Z1fA37_iPS_", 0, 0, &status);
puts(p);
return 0;
}
~/c++/demangle_lib2>make
g++ -g -O2 -fno-exceptions -D_GLIBCPP_DEMANGLER_NOSTDCPP -c demangle.cc
ar cru libdemangle.a demangle.o
gcc -g test_dem.o libdemangle.a -liberty -o test_dem
~/c++/demangle_lib2>test_dem
f(int[37], int (*) [37])
~/c++/demangle_lib2>ldd test_dem
libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
This was somewhere in April.
If it is a problem that one needs a C++ compiler to generate
libdemangle.a, then I'd say: you can distribute that as binary
in order to allow people to produce libiberty without needing
a C++ compiler.
~/c++/demangle_lib2>strip libdemangle.a
~/c++/demangle_lib2>ls -l libdemangle.a
-rw-r--r-- 1 carlo carlo 27572 Jun 28 00:36 libdemangle.a
Note that the REAL demangle (code) resides in demangle.h - which
has very small parts of code inside #ifdef _GLIBCPP_DEMANGLER_NOSTDCPP
... #endif, no maintaining problem at all.
The demangle.cc used above to produce libdemangle.a is pretty small
and actually just a wrapper for this demangle.h.
-rw-r--r-- 1 carlo carlo 7647 Apr 15 03:05 demangle.cc
--
Carlo Wood <carlo@alinoe.com>