avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] adding wrapper functions for new and delete operators


From: Bradley Jarvis
Subject: Re: [avr-libc-dev] adding wrapper functions for new and delete operators
Date: Sun, 13 Feb 2011 21:25:33 +1100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20110114 Lightning/1.0b2 Thunderbird/3.1.7

On 02/13/11 04:01, address@hidden wrote:
>  The new / delete operators can be put in a different namespace in order to
> avoid any name collisions with the new/delete in the std namespace.
> the header could still be called new and then just put it in the compat
> directory (compat/new) to differentiate it from the standards compliant new
> header.
The header file is not needed as Joerg pointed out, I have tried to
define the operators as inline in a header since they only wrap the
malloc and free functions however this does not seem to work and I end
up getting errors because of multiple instances. So I have had a look at
adding the wrappers to the stdlib library in a new file called new.c
that basically contains

void* operator new(size_t __s) {return malloc(__s);}
void* operator new[](size_t __s) {return malloc(__s);}
void operator delete(void* __p) {free(__p);}
void operator delete[](void* __p) {free(__p);}

The only problem though is the the compiler baulks at the c++ stuff
while building avr-libc. I tried encapsulating in extern "c++" {} but it
did not seem to help. I will keep playing around with it, but am open to
suggestions on what to try.

Regards Brad



reply via email to

[Prev in Thread] Current Thread [Next in Thread]