From 181f6423aed55cce7ffa2adfd05374a017a41355 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Thu, 6 Jan 2022 11:15:23 +0100 Subject: [PATCH 1/7] makefiles/cflags: enable C++14 by default --- makefiles/cflags.inc.mk | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/makefiles/cflags.inc.mk b/makefiles/cflags.inc.mk index a4779b1406..9b8be48546 100644 --- a/makefiles/cflags.inc.mk +++ b/makefiles/cflags.inc.mk @@ -45,6 +45,12 @@ OPTIONAL_CFLAGS += -Wold-style-definition CXXUWFLAGS += -std=% CXXUWFLAGS += -Wstrict-prototypes -Wold-style-definition +ifeq ($(filter -std=%,$(CXXEXFLAGS)),) + ifeq ($(shell $(CC) -std=c++14 -E - 2>/dev/null >/dev/null Date: Thu, 6 Jan 2022 11:18:33 +0100 Subject: [PATCH 2/7] sys/cpp11-compat: add deleted operators required by C++14 --- sys/cpp11-compat/cppsupport.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sys/cpp11-compat/cppsupport.cpp b/sys/cpp11-compat/cppsupport.cpp index 06026caf52..c998821306 100644 --- a/sys/cpp11-compat/cppsupport.cpp +++ b/sys/cpp11-compat/cppsupport.cpp @@ -119,4 +119,18 @@ void operator delete[](void* ptr, const std::nothrow_t&) noexcept { std::free(ptr); } +/* end of tinynew.cpp */ + +/* additional delete operators required by C++14 */ + +void operator delete (void* ptr, std::size_t, + const std::nothrow_t&) noexcept { + std::free(ptr); +} + +void operator delete[] (void* ptr, std::size_t, + const std::nothrow_t&) noexcept { + std::free(ptr); +} + /** @} */ From a0f0d2ea43cfde933f4307cd79bbc5d2043acf79 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Thu, 6 Jan 2022 11:18:50 +0100 Subject: [PATCH 3/7] sys/cpp_new_delete: add deleted operators required by C++14 --- sys/cpp_new_delete/new_delete.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/cpp_new_delete/new_delete.cpp b/sys/cpp_new_delete/new_delete.cpp index 7d88661518..28a78c0d34 100644 --- a/sys/cpp_new_delete/new_delete.cpp +++ b/sys/cpp_new_delete/new_delete.cpp @@ -14,6 +14,8 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * SPDX-License-Identifier: LGPL-2.1-or-later */ #include @@ -35,6 +37,14 @@ void operator delete(void *ptr) { free(ptr); } +void operator delete(void *ptr, size_t) noexcept { + free(ptr); +} + void operator delete[](void *ptr) { free(ptr); } + +void operator delete [](void *ptr, size_t) noexcept { + free(ptr); +} From 60793f14aef5435b4185ba662fecd7a2f0a27c96 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Thu, 6 Jan 2022 11:19:49 +0100 Subject: [PATCH 4/7] cpu/esp*/vendor: remove -std=c++11 --- cpu/esp32/vendor/esp-idf/nvs_flash/Makefile | 1 - cpu/esp8266/vendor/esp-idf/nvs_flash/src/Makefile | 1 - 2 files changed, 2 deletions(-) diff --git a/cpu/esp32/vendor/esp-idf/nvs_flash/Makefile b/cpu/esp32/vendor/esp-idf/nvs_flash/Makefile index f92caf4df7..41bd59f255 100644 --- a/cpu/esp32/vendor/esp-idf/nvs_flash/Makefile +++ b/cpu/esp32/vendor/esp-idf/nvs_flash/Makefile @@ -3,7 +3,6 @@ MODULE=esp_idf_nvs_flash include $(RIOTBASE)/Makefile.base CFLAGS += -DESP_PLATFORM -CXXFLAGS += -std=c++11 INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/include/log INCLUDES += -I$(ESP32_SDK_DIR)/components/nvs_flash/include INCLUDES += -I$(ESP32_SDK_DIR)/components/spi_flash/include diff --git a/cpu/esp8266/vendor/esp-idf/nvs_flash/src/Makefile b/cpu/esp8266/vendor/esp-idf/nvs_flash/src/Makefile index 315ae9edaf..ef469cae59 100644 --- a/cpu/esp8266/vendor/esp-idf/nvs_flash/src/Makefile +++ b/cpu/esp8266/vendor/esp-idf/nvs_flash/src/Makefile @@ -3,6 +3,5 @@ MODULE=esp_idf_nvs_flash include $(RIOTBASE)/Makefile.base CFLAGS += -DESP_PLATFORM -DNVS_CRC_HEADER_FILE=\"crc.h\" -CXXFLAGS += -std=c++11 INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/nvs_flash/include INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/util/include From aa44c8ab7889344e6762a5cde07a0bfbd38961d1 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Thu, 6 Jan 2022 11:20:14 +0100 Subject: [PATCH 5/7] pkg: remove -std=c++11 --- pkg/arduino_api/Makefile.include | 2 -- pkg/flatbuffers/Makefile.include | 3 --- pkg/talking_leds/Makefile.include | 2 -- pkg/utensor/Makefile.include | 4 ---- 4 files changed, 11 deletions(-) diff --git a/pkg/arduino_api/Makefile.include b/pkg/arduino_api/Makefile.include index d8d5bd0cbe..3987ecabda 100644 --- a/pkg/arduino_api/Makefile.include +++ b/pkg/arduino_api/Makefile.include @@ -1,3 +1 @@ INCLUDES += -I$(PKGDIRBASE)/arduino_api/api - -CXXEXFLAGS += -std=c++11 diff --git a/pkg/flatbuffers/Makefile.include b/pkg/flatbuffers/Makefile.include index 1a399bee76..f234b0a7e5 100644 --- a/pkg/flatbuffers/Makefile.include +++ b/pkg/flatbuffers/Makefile.include @@ -7,8 +7,5 @@ ifneq (0,$(shell which flatc > /dev/null 2>&1 ; echo $$?)) $(call target-export-variables,all,FLATC) endif -# This module requires cpp11 support -CXXEXFLAGS += -std=c++11 - # This package is a header only package, so there's nothing to build PSEUDOMODULES += flatbuffers diff --git a/pkg/talking_leds/Makefile.include b/pkg/talking_leds/Makefile.include index 102cad5aad..7340b5eec2 100644 --- a/pkg/talking_leds/Makefile.include +++ b/pkg/talking_leds/Makefile.include @@ -1,3 +1 @@ INCLUDES += -I$(PKGDIRBASE)/talking_leds/src - -CXXEXFLAGS += -std=c++11 diff --git a/pkg/utensor/Makefile.include b/pkg/utensor/Makefile.include index 6b0ee8302c..829f5da897 100644 --- a/pkg/utensor/Makefile.include +++ b/pkg/utensor/Makefile.include @@ -11,7 +11,3 @@ ifeq (llvm,$(TOOLCHAIN)) CXXEXFLAGS += -Wno-unused-variable CXXEXFLAGS += -Wno-shift-count-negative endif - -ifneq (native,$(BOARD)) - CXXEXFLAGS += -std=c++11 -endif From 20dfe4033047ec1bb2cd216a0f2ebf860263b84e Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Thu, 6 Jan 2022 11:20:41 +0100 Subject: [PATCH 6/7] sys: remove -std=c++11 --- sys/arduino/Makefile.include | 5 ----- sys/cpp11-compat/Makefile | 3 --- sys/cpp_new_delete/Makefile | 2 -- 3 files changed, 10 deletions(-) diff --git a/sys/arduino/Makefile.include b/sys/arduino/Makefile.include index c9a218d7db..1adec285ca 100644 --- a/sys/arduino/Makefile.include +++ b/sys/arduino/Makefile.include @@ -20,9 +20,4 @@ endif # include the Arduino headers INCLUDES += -I$(RIOTBASE)/sys/arduino/include -# Arduino provices C++11, which is not enabled by default in Ubuntu's avr-gcc -# package, which is __horrible__ out of date. However, we cannot simply ignore -# all Ubuntu users and instead simply manually enable C++11 support -CXXEXFLAGS += -std=c++11 - PSEUDOMODULES += arduino_pwm diff --git a/sys/cpp11-compat/Makefile b/sys/cpp11-compat/Makefile index 9e24ecf137..48422e909a 100644 --- a/sys/cpp11-compat/Makefile +++ b/sys/cpp11-compat/Makefile @@ -1,4 +1 @@ -# This module requires cpp 11 -CXXEXFLAGS += -std=c++11 - include $(RIOTBASE)/Makefile.base diff --git a/sys/cpp_new_delete/Makefile b/sys/cpp_new_delete/Makefile index 025387e061..48422e909a 100644 --- a/sys/cpp_new_delete/Makefile +++ b/sys/cpp_new_delete/Makefile @@ -1,3 +1 @@ include $(RIOTBASE)/Makefile.base - -CXXFLAGS += -std=c++11 From 93d15ac2d30a8f061fc3c2a3266464a9d53f2fce Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Thu, 6 Jan 2022 11:21:00 +0100 Subject: [PATCH 7/7] tests/cpp11_*: remove -std=c++11 --- tests/cpp11_condition_variable/Makefile | 4 ---- tests/cpp11_mutex/Makefile | 4 ---- tests/cpp11_thread/Makefile | 4 ---- 3 files changed, 12 deletions(-) diff --git a/tests/cpp11_condition_variable/Makefile b/tests/cpp11_condition_variable/Makefile index 4414051886..cf2c81d3a9 100644 --- a/tests/cpp11_condition_variable/Makefile +++ b/tests/cpp11_condition_variable/Makefile @@ -1,9 +1,5 @@ include ../Makefile.tests_common -# If you want to add some extra flags when compile c++ files, add these flags -# to CXXEXFLAGS variable -CXXEXFLAGS += -std=c++11 - # nucleo-f303k8 doesn't have enough RAM to run the test so we reduce the stack # size for every thread ifneq (,$(filter nucleo-f303k8 nucleo-f334r8,$(BOARD))) diff --git a/tests/cpp11_mutex/Makefile b/tests/cpp11_mutex/Makefile index 4038dfcec4..6ec1d9fd36 100644 --- a/tests/cpp11_mutex/Makefile +++ b/tests/cpp11_mutex/Makefile @@ -1,9 +1,5 @@ include ../Makefile.tests_common -# If you want to add some extra flags when compile c++ files, add these flags -# to CXXEXFLAGS variable -CXXEXFLAGS += -std=c++11 - USEMODULE += cpp11-compat USEMODULE += xtimer diff --git a/tests/cpp11_thread/Makefile b/tests/cpp11_thread/Makefile index 8c443eb721..81920c7871 100644 --- a/tests/cpp11_thread/Makefile +++ b/tests/cpp11_thread/Makefile @@ -1,9 +1,5 @@ include ../Makefile.tests_common -# If you want to add some extra flags when compile c++ files, add these flags -# to CXXEXFLAGS variable -CXXEXFLAGS += -std=c++11 - USEMODULE += cpp11-compat USEMODULE += xtimer USEMODULE += timex