Atmel CAVR-4 Manual De Usuario
![Atmel](https://files.manualsbrain.com/attachments/0369829915bda09f9c2e00fb805a7753579683b5/common/fit/150/50/8d2bf08978ec3e5bc63f4343ac5e91ce8d0e40045619fa520d910d64af8f/brand_logo.png)
CAVR-4
Part 1. Using the compiler
Using C++
119
NAMESPACE
The namespace feature is only supported in Extended EC++. This means that you can
use namespaces to partition your code. Note, however, that the library itself is not placed
in the
use namespaces to partition your code. Note, however, that the library itself is not placed
in the
std
namespace.
THE STD NAMESPACE
The
std
namespace is not used in either standard EC++ or in Extended EC++. If you
have code that refers to symbols in the
std
namespace, simply define
std
as nothing;
for example:
#define std // Nothing here
POINTER TO MEMBER FUNCTIONS
A pointer to a member function can only contain a default function pointer, or a function
pointer that can implicitly be casted to a default function pointer. To use a pointer to a
member function, make sure that all functions that should be pointed to reside in the
default memory or a memory contained in the default memory.
pointer that can implicitly be casted to a default function pointer. To use a pointer to a
member function, make sure that all functions that should be pointed to reside in the
default memory or a memory contained in the default memory.
Example
class X{
public:
_ _nearfunc void f();
};
void (_ _nearfunc X::*pmf)(void) = &X::f;
USING INTERRUPTS AND EC++ DESTRUCTORS
If interrupts are enabled and the interrupt functions use class objects that have
destructors, there may be problems if the program exits either by using
destructors, there may be problems if the program exits either by using
exit
or by
returning from
main
. If an interrupt occurs after an object has been destroyed, there is
no guarantee that the program will work properly.
To avoid this, you must override the function
exit(int)
.
The standard implementation of this function (located in the file
exit.c
) looks like this:
extern void _exit(int arg);
void exit(int arg)
{
_exit(arg);
}
_exit(int)
is responsible for calling the destructors of global class objects before
ending the program.