I am sceptical of reports of C++ generating more machine code than C. My simple test shows only a little increase in code size.
I found a simple C Xmega program that blinks a LED using delay_ms. I made a copy and replaced the three C style port I/O functions with C++ functions in the copy. The resulting C++ program was 8 bytes bigger than the C program.
8 bytes out of 600 is trivial to me. However It does seem that the system is reserving half of the 800 for interrupt vectors or something for my Xmega 128a4u. So that would make it 8 out of 300 bytes. Still nothing compared to the skin rashes and headaches I would get just thinking of using C. :)
If we could get a bit more complex program to compare, that would be good. If someone could find a C blinker program for the Xmega that uses RTC instead of delay_ms, that would be great. I could easily add RTC to the c++ program.
One reason for the bigger C++ program could be that the C++ compiler doesn't produce as good AVR code. I took a quick look at the .lss files and I noticed one place where the C compiler used rcall and rjmp and the C++ compiler used call and jmp. I don't know much about the AVR instructions, but it seems the call could be replaced with rcall. That would save 2 bytes. Maybe the jmp could be replaces with rjmp also, but I don't know how far the rjmp can jump.
C compiler
214: 02 d0 rcall .+4 ; 0x21a <main>
216: 1b c0 rjmp .+54 ; 0x24e <_exit>
CPP compiler
214: 0e 94 10 01 call 0x220 ; 0x220 <main>
218: 0c 94 2b 01 jmp 0x256 ; 0x256 <_exit>
I'm using the C++ compiler that came with the last Atmel Studio 7 Version 7.0.2397
gcc version 4.6.2
I am attaching main.c and main.cpp. Also the 2 studio projects.