Atmel CAVR-4 ユーザーズマニュアル
CAVR-4
114
Feature descriptions
AVR® IAR C/C++ Compiler
Reference Guide
To override the default
new
and
delete
operator for a class, declare:
void *operator new(size_t);
void operator delete(void *);
as member functions, just like in ordinary C++.
If a pointer to class memory cannot be implicitly casted into a default pointer type, no
temporaries can be created for that class.
temporaries can be created for that class.
For more information about memory types, see Memory types and memory attributes,
page 18.
page 18.
FUNCTIONS
A function with
extern
"C"
linkage is compatible with a function that has C++ linkage.
Example
extern "C" {
typedef void (*fpC)(void); // A C function typedef
};
void (*fpCpp)(void); // A C++ function typedef
fpC f1;
fpCpp f2;
void f(fpC);
f(f1); // Always works
f(f2); // fpCpp is compatible with fpC
NEW AND DELETE OPERATORS
There are operators for
new
and
delete
for each memory that can have a heap, that is,
tiny, near, far, and huge memory.
These examples assume that there is a heap in both near and far memory.
void _ _near * operator new _ _near (_ _near_size_t);
void _ _tiny * operator new _ _tiny (_ _tiny_size_t);
void operator delete(void _ _near *);
void operator delete(void _ _tiny *);
And correspondingly for array
new
and
delete
operators:
void _ _near * operator new[] _ _near (_ _near_size_t);
void _ _tiny * operator new[] _ _tiny (_ _tiny_size_t);
void operator delete[](void _ _near *);
void operator delete[](void _ _tiny *);