From owner-freebsd-hackers Sat Feb 10 13:55:52 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from fortune.excite.com (fortune-rwcmta.excite.com [198.3.99.203]) by hub.freebsd.org (Postfix) with ESMTP id 5E53F37B401 for ; Sat, 10 Feb 2001 13:55:31 -0800 (PST) Received: from pugsly.excite.com ([199.172.148.160]) by fortune.excite.com (InterMail vM.4.01.02.39 201-229-119-122) with ESMTP id <20010210215530.SKBI12032.fortune.excite.com@pugsly.excite.com>; Sat, 10 Feb 2001 13:55:30 -0800 Message-ID: <28330970.981842130266.JavaMail.imail@pugsly.excite.com> Date: Sat, 10 Feb 2001 13:55:29 -0800 (PST) From: John Wilson To: Jordan Hubbard Subject: Re: operator new with C++ and pthreads Cc: freebsd-hackers@FreeBSD.ORG Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Excite Inbox X-Sender-Ip: 192.116.157.236 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Thanks for your reply, Jordan. -fno-builtin doesn't seem to work. Consider the following simple scenario: -------- my_new.h -------- #include inline void *operator new(size_t size); --------- my_new.cc --------- #include #include #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