diff --git a/avr/boards.txt b/avr/boards.txt index dd49ec7e8..249782148 100644 --- a/avr/boards.txt +++ b/avr/boards.txt @@ -34,6 +34,7 @@ menu.LTO=Compiler LTO menu.variant=Variant menu.pinout=Pinout menu.bootloader=Bootloader +menu.CppLanguageStandard=C++ Language Standard ###################### @@ -241,6 +242,20 @@ menu.bootloader=Bootloader 1284.menu.clock.1MHz_internal.build.f_cpu=1000000L +# C++ Language Standard +1284.menu.CppLanguageStandard.Default=Default + +1284.menu.CppLanguageStandard.Cpp11=C++11 +1284.menu.CppLanguageStandard.Cpp11.compiler.cpp.languageStandard=-std=gnu++11 + +1284.menu.CppLanguageStandard.Cpp14=C++14 +1284.menu.CppLanguageStandard.Cpp14.compiler.cpp.languageStandard=-std=gnu++14 + +1284.menu.CppLanguageStandard.Cpp17=C++17 +1284.menu.CppLanguageStandard.Cpp17.compiler.cpp.languageStandard=-std=gnu++17 + + + ########################### #### ATmega644/A/P/PA #### @@ -446,6 +461,19 @@ menu.bootloader=Bootloader 644.menu.clock.1MHz_internal.build.clock_speed={build.f_cpu} 644.menu.clock.1MHz_internal.build.f_cpu=1000000L +# C++ Language Standard +644.menu.CppLanguageStandard.Default=Default +644.menu.CppLanguageStandard.Default.compiler.cpp.extra_flags= + +644.menu.CppLanguageStandard.Cpp11=C++11 +644.menu.CppLanguageStandard.Cpp11.compiler.cpp.extra_flags=-std=gnu++11 + +644.menu.CppLanguageStandard.Cpp14=C++14 +644.menu.CppLanguageStandard.Cpp14.compiler.cpp.extra_flags=-std=gnu++14 + +644.menu.CppLanguageStandard.Cpp17=C++17 +644.menu.CppLanguageStandard.Cpp17.compiler.cpp.extra_flags=-std=gnu++17 + ########################## @@ -672,6 +700,19 @@ menu.bootloader=Bootloader 324.menu.clock.1MHz_internal.build.clock_speed={build.f_cpu} 324.menu.clock.1MHz_internal.build.f_cpu=1000000L +# C++ Language Standard +324.menu.CppLanguageStandard.Default=Default +324.menu.CppLanguageStandard.Default.compiler.cpp.extra_flags= + +324.menu.CppLanguageStandard.Cpp11=C++11 +324.menu.CppLanguageStandard.Cpp11.compiler.cpp.extra_flags=-std=gnu++11 + +324.menu.CppLanguageStandard.Cpp14=C++14 +324.menu.CppLanguageStandard.Cpp14.compiler.cpp.extra_flags=-std=gnu++14 + +324.menu.CppLanguageStandard.Cpp17=C++17 +324.menu.CppLanguageStandard.Cpp17.compiler.cpp.extra_flags=-std=gnu++17 + ########################## @@ -878,6 +919,19 @@ menu.bootloader=Bootloader 164.menu.clock.1MHz_internal.build.clock_speed={build.f_cpu} 164.menu.clock.1MHz_internal.build.f_cpu=1000000L +# C++ Language Standard +164.menu.CppLanguageStandard.Default=Default +164.menu.CppLanguageStandard.Default.compiler.cpp.extra_flags= + +164.menu.CppLanguageStandard.Cpp11=C++11 +164.menu.CppLanguageStandard.Cpp11.compiler.cpp.extra_flags=-std=gnu++11 + +164.menu.CppLanguageStandard.Cpp14=C++14 +164.menu.CppLanguageStandard.Cpp14.compiler.cpp.extra_flags=-std=gnu++14 + +164.menu.CppLanguageStandard.Cpp17=C++17 +164.menu.CppLanguageStandard.Cpp17.compiler.cpp.extra_flags=-std=gnu++17 + ##################### @@ -1053,6 +1107,19 @@ menu.bootloader=Bootloader 32.menu.clock.1MHz_internal.bootloader.ckopt_bit=1 32.menu.clock.1MHz_internal.build.f_cpu=1000000L +# C++ Language Standard +32.menu.CppLanguageStandard.Default=Default +32.menu.CppLanguageStandard.Default.compiler.cpp.extra_flags= + +32.menu.CppLanguageStandard.Cpp11=C++11 +32.menu.CppLanguageStandard.Cpp11.compiler.cpp.extra_flags=-std=gnu++11 + +32.menu.CppLanguageStandard.Cpp14=C++14 +32.menu.CppLanguageStandard.Cpp14.compiler.cpp.extra_flags=-std=gnu++14 + +32.menu.CppLanguageStandard.Cpp17=C++17 +32.menu.CppLanguageStandard.Cpp17.compiler.cpp.extra_flags=-std=gnu++17 + ##################### @@ -1228,6 +1295,19 @@ menu.bootloader=Bootloader 16.menu.clock.1MHz_internal.bootloader.ckopt_bit=1 16.menu.clock.1MHz_internal.build.f_cpu=1000000L +# C++ Language Standard +16.menu.CppLanguageStandard.Default=Default +16.menu.CppLanguageStandard.Default.compiler.cpp.extra_flags= + +16.menu.CppLanguageStandard.Cpp11=C++11 +16.menu.CppLanguageStandard.Cpp11.compiler.cpp.extra_flags=-std=gnu++11 + +16.menu.CppLanguageStandard.Cpp14=C++14 +16.menu.CppLanguageStandard.Cpp14.compiler.cpp.extra_flags=-std=gnu++14 + +16.menu.CppLanguageStandard.Cpp17=C++17 +16.menu.CppLanguageStandard.Cpp17.compiler.cpp.extra_flags=-std=gnu++17 + ##################### @@ -1402,3 +1482,16 @@ menu.bootloader=Bootloader 8535.menu.clock.1MHz_internal.bootloader.sut_cksel_bits=100001 8535.menu.clock.1MHz_internal.bootloader.ckopt_bit=1 8535.menu.clock.1MHz_internal.build.f_cpu=1000000L + +# C++ Language Standard +8535.menu.CppLanguageStandard.Default=Default +8535.menu.CppLanguageStandard.Default.compiler.cpp.extra_flags= + +8535.menu.CppLanguageStandard.Cpp11=C++11 +8535.menu.CppLanguageStandard.Cpp11.compiler.cpp.extra_flags=-std=gnu++11 + +8535.menu.CppLanguageStandard.Cpp14=C++14 +8535.menu.CppLanguageStandard.Cpp14.compiler.cpp.extra_flags=-std=gnu++14 + +8535.menu.CppLanguageStandard.Cpp17=C++17 +8535.menu.CppLanguageStandard.Cpp17.compiler.cpp.extra_flags=-std=gnu++17 diff --git a/avr/cores/MCUdude_corefiles/new.cpp b/avr/cores/MCUdude_corefiles/new.cpp index cf6f89c17..69a4a07a0 100755 --- a/avr/cores/MCUdude_corefiles/new.cpp +++ b/avr/cores/MCUdude_corefiles/new.cpp @@ -34,3 +34,18 @@ void operator delete[](void * ptr) { free(ptr); } +// C++14 introduces additional delete operators +#if __cplusplus >= 201402L + +void operator delete(void * ptr, size_t) +{ + ::operator delete(ptr); +} + +void operator delete[](void * ptr, size_t) +{ + ::operator delete(ptr); +} + +#endif // end language is C++14 or greater + diff --git a/avr/cores/MCUdude_corefiles/new.h b/avr/cores/MCUdude_corefiles/new.h index 6e1b68f0d..a8a270502 100755 --- a/avr/cores/MCUdude_corefiles/new.h +++ b/avr/cores/MCUdude_corefiles/new.h @@ -26,5 +26,11 @@ void * operator new[](size_t size); void operator delete(void * ptr); void operator delete[](void * ptr); +// C++14 introduces additional delete operators +#if __cplusplus >= 201402L +void operator delete(void * ptr, size_t); +void operator delete[](void * ptr, size_t); +#endif // end language is C++14 or greater + #endif diff --git a/avr/platform.txt b/avr/platform.txt index 6ae247ded..f032d7c6c 100644 --- a/avr/platform.txt +++ b/avr/platform.txt @@ -17,15 +17,18 @@ compiler.warning_flags.default= compiler.warning_flags.more=-Wall compiler.warning_flags.all=-Wall -Wextra +compiler.c.languageStandard=-std=gnu11 +compiler.cpp.languageStandard=-std=gnu++17 + # Default "compiler.path" is correct, change only if you want to overidde the initial value compiler.path={runtime.tools.avr-gcc.path}/bin/ compiler.c.cmd=avr-gcc -compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD +compiler.c.flags=-c -g -Os {compiler.warning_flags} {compiler.c.languageStandard} -ffunction-sections -fdata-sections -MMD compiler.c.elf.flags={compiler.warning_flags} -Os -Wl,--gc-sections,--section-start=.FAR_MEM1=0x10000 compiler.c.elf.cmd=avr-gcc compiler.S.flags=-c -g -x assembler-with-cpp compiler.cpp.cmd=avr-g++ -compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD +compiler.cpp.flags=-c -g -Os {compiler.warning_flags} {compiler.cpp.languageStandard} -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD compiler.ar.cmd={ltoarcmd} compiler.ar.flags=rcs compiler.objcopy.cmd=avr-objcopy