Hi
I use avr-gcc for c++ code (have so for years) and wanted to use new and
delete, particularly for libraries that I have written for and used in
an x86 environment which I didn't want to have to convert. So I wrote
the following wrapper functions, please feel free to add it to avr-libc
To go into a header file (not sure what the standard c++ header file new
and delete function would normally exist in, that that is where the
declarations would reside):
void *operator new(size_t);
void *operator new[](size_t);
void operator delete(void *);
void operator delete[](void *);
To go into the source file:
void *operator new(size_t s)
{
return malloc(s);
}
void *operator new[](size_t s)
{
return malloc(s);
}
void operator delete(void *m)
{
free(m);
}
void operator delete[](void *m)
{
free(m);
}
I have used these functions for years to get new and delete
functionality into my avr-gcc code.
BTW get job on the gcc avr support, it's a fantastic product. The only
other thing I would like to use that is not supported are exceptions, it
would make some software easier.
Thanks Brad