On 02/13/11 04:01, avr-libc-dev-requ...@nongnu.org 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

_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to