Eero Tamminen, 17.04.2013 12:45:47:
Hi, On keskiviikko 17 huhtikuu 2013, Helmut Karlowski wrote:Andreas Schwab, 17.04.2013 11:16:34: > "Helmut Karlowski" <helmut.karlowski@ish.de> writes: >> Why doesn't it find the reference when they are the same? > > Because nothing defines it. libc does.C "wcslen" and your C++ "wcslen" have completely different symbol names. C++ one is mangled, so C one in libc doesn't match it. It may be easier if you use "nm" on your C++ compiled object files to see what are the actual symbol names for the functions included in it.
When I compile this:
extern "C"
{
extern int wcslen(const int * s);
}
int xwcslen(int const* s)
{
return wcslen( (const int*)s);
}
I get:
.file "wcs.cpp"
.text
.globl __Z7xwcslenPKi
.def __Z7xwcslenPKi; .scl 2; .type 32; .endef
__Z7xwcslenPKi:
LFB0:
pushl %ebp
LCFI0:
movl %esp, %ebp
LCFI1:
subl $24, %esp
LCFI2:
movl 8(%ebp), %eax
movl %eax, (%esp)
call _wcslen
leave
LCFI3:
ret
LFE0:
.def _wcslen; .scl 2; .type 32; .endef
So there would be no recursion.
--
Helmut Karlowski