Mail Archives: djgpp/1999/12/15/03:23:28
On Tue, 14 Dec 1999, Sven Sandberg wrote:
> -------- source file: test.cc ---------
> #include <stdlib.h>
> extern void *__real_malloc(size_t size);
> void *__wrap_malloc(int c)
> {
> return __real_malloc(c);
> }
> int main(void)
> {
> free(malloc(4711));
> return 0;
> }
> -------- eof(test.cc) -----------------
>
> command line:
> gcc -Wl,--wrap,malloc -o test.exe test.cc -W -Wall
>
> -------- error messages ---------------
> test.o(.text+0xe):test.cc: undefined reference to
> `__real_malloc(unsigned long)'
> test.o(.text+0x33):test.cc: undefined reference to `__wrap_malloc'
I think both __wrap_malloc and __real_malloc should be declared as
``extern "C"'' in a C++ program.
- Raw text -