Date: Sat, 10 Feb 2001 13:55:29 -0800 (PST) From: John Wilson <john_wilson100@excite.com> To: Jordan Hubbard <jkh@winston.osd.bsdi.com> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: operator new with C++ and pthreads Message-ID: <28330970.981842130266.JavaMail.imail@pugsly.excite.com>
next in thread | raw e-mail | index | archive | help
Thanks for your reply, Jordan. -fno-builtin doesn't seem to work.
Consider the following simple scenario:
--------
my_new.h
--------
#include <sys/types.h>
inline void *operator new(size_t size);
---------
my_new.cc
---------
#include <stdio.h>
#include <stdlib.h>
#include "my_new.h"
inline void *operator new(size_t size)
{
printf("my new was called with size = %u\n", size);
return malloc(size);
}
-----------
new_test.cc
-----------
#include "my_new.h"
class Foo
{
int a, b;
};
int
main(int argc, char *argv[])
{
Foo *p;
p = new Foo;
return 0;
}
Compile it as follows:
g++ -fno-builtin -c -o my_new.o my_new.cc
g++ -fno-builtin -c -o new_test.o new_test.cc
g++ -fno-builtin -o new_test new_test.o my_new.o
new_test doesn't print anything (which it should, if it were linked with
my_new.o)
John Wilson
On Sat, 10 Feb 2001 08:53:26 -0800, Jordan Hubbard wrote:
> > but gcc (g++) doesn't seem to want to link them in, and uses its own
> > __builtin_new and __builtin_delete instead.
>
> You need to compile everything with -fno-builtin so that g++ won't
> try to use its own versions but yours instead.
>
> - Jordan
_______________________________________________________
Send a cool gift with your E-Card
http://www.bluemountain.com/giftcenter/
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?28330970.981842130266.JavaMail.imail>
