.cc
, .cpp
or .C
will automatically cause the compiler frontend to invoke the C++ compiler. Alternatively, the C++ compiler could be explicitly called by the name avr-c++
.
However, there's currently no support for libstdc++
, the standard support library needed for a complete C++ implementation. This imposes a number of restrictions on the C++ programs that can be compiled. Among them are:
new
and delete
are not implemented, attempting to use them will cause the linker to complain about undefined external references. (This could perhaps be fixed.)
extern "C" { . . . }(This could certainly be fixed, too.)
-fno-exceptions
in the compiler options. Failing this, the linker will complain about an undefined external reference to __gxx_personality_sj0
.Constructors and destructors are supported though, including global ones.
When programming C++ in space- and runtime-sensitive environments like microcontrollers, extra care should be taken to avoid unwanted side effects of the C++ calling conventions like implied copy constructors that could be called upon function invocation etc. These things could easily add up into a considerable amount of time and program memory wasted. Thus, casual inspection of the generated assembler code (using the -S
compiler option) seems to be warranted.