Specifications

CAVR-4
112
Feature descriptions
AVR® IAR C/C++ Compiler
Reference Guide
Example
class B {
public:
void f();
int i;
};
Class memory
To compensate for this limitation, a class can be associated with a class memory type.
The class memory type changes:
the this pointer type in all member functions, constructors, and destructors into a
pointer to class memory
the default memory for static storage duration variables—that is, not auto
variables—of the class type, into the specified class memory
the pointer type used for pointing to objects of the class type, into a pointer to class
memory.
Example
class __far C {
public:
void f(); // Has a this pointer of type C __far *
void f() const; // Has a this pointer of type
// C __far const *
C(); // Has a this pointer pointing into far
// memory
C(C const &); // Takes a parameter of type C __far const &
// (also true of generated copy constructor)
int i;
};
C Ca; // Resides in far memory instead of the
// default memory
C __near Cb; // Resides in near memory, the 'this'
// pointer still points into far memory
C __huge Cc; // Not allowed, __huge pointer can't be
// implicitly casted into a __far pointer
void h()
{
C Cd; // Resides on the stack
}
C * Cp; // Creates a pointer to far memory
C __near * Cp; // Creates a pointer to near memory