From d81d769e6802d32b98dd3e36748c54e3bfc795cd Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Tue, 16 Jun 2020 13:02:53 -0700 Subject: [PATCH] [style] advance C++ language standard to C++11 (#5077) --- .clang-format | 2 +- Android.mk | 10 ++++++++++ STYLE_GUIDE.md | 2 +- configure.ac | 2 +- tests/fuzz/fuzzer_platform.cpp | 7 +++++-- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.clang-format b/.clang-format index 9a0a6ea50..b5b25e775 100644 --- a/.clang-format +++ b/.clang-format @@ -105,7 +105,7 @@ SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: Cpp03 +Standard: Cpp11 TabWidth: 4 UseTab: Never ... diff --git a/Android.mk b/Android.mk index fc0432ae9..ae4356ca4 100644 --- a/Android.mk +++ b/Android.mk @@ -137,6 +137,8 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := \ $(NULL) LOCAL_CPPFLAGS := \ + -std=c++11 \ + -pedantic-errors \ -Wno-non-virtual-dtor \ $(NULL) @@ -342,6 +344,8 @@ LOCAL_CFLAGS := \ $(NULL) LOCAL_CPPFLAGS := \ + -std=c++11 \ + -pedantic-errors \ -Wno-non-virtual-dtor \ $(NULL) @@ -385,6 +389,8 @@ LOCAL_CFLAGS := \ $(NULL) LOCAL_CPPFLAGS := \ + -std=c++11 \ + -pedantic-errors \ -Wno-non-virtual-dtor \ $(NULL) @@ -422,6 +428,8 @@ LOCAL_CFLAGS := \ $(NULL) LOCAL_CPPFLAGS := \ + -std=c++11 \ + -pedantic-errors \ -Wno-non-virtual-dtor \ $(NULL) @@ -462,6 +470,8 @@ LOCAL_CFLAGS := \ $(NULL) LOCAL_CPPFLAGS := \ + -std=c++11 \ + -pedantic-errors \ -Wno-non-virtual-dtor \ $(NULL) diff --git a/STYLE_GUIDE.md b/STYLE_GUIDE.md index f50a7b116..ae507cc73 100644 --- a/STYLE_GUIDE.md +++ b/STYLE_GUIDE.md @@ -18,7 +18,7 @@ - C - OpenThread uses and enforces the ISO9899:1999 (aka ISO C99, C99) C language standard as the minimum. - C++ - - OpenThread uses and enforces the ISO14882:2003 (aka ISO C++03, C++03) C++ language standard as the minimum. + - OpenThread uses and enforces the ISO14882:2011 (aka ISO C++11, C++11) C++ language standard as the minimum. - Extensions - Wherever possible, toolchain-specific (e.g GCC/GNU) extensions or the use of later standards shall be avoided or shall be leveraged through toolchain-compatibility preprocessor macros. diff --git a/configure.ac b/configure.ac index f4658d528..f91bea9e2 100644 --- a/configure.ac +++ b/configure.ac @@ -227,7 +227,7 @@ AC_PROG_LIBTOOL # PROSPECTIVE_CFLAGS="-Wall -Wextra -Wshadow -Wundef -Wcast-align -Werror -Wno-error=undef -std=c99 -pedantic-errors" -PROSPECTIVE_CXXFLAGS="-Wall -Wextra -Wshadow -Wundef -Wcast-align -Werror -Wno-error=undef -std=gnu++98 -Wno-c++14-compat -fno-exceptions" +PROSPECTIVE_CXXFLAGS="-Wall -Wextra -Wshadow -Wundef -Wcast-align -Werror -Wno-error=undef -std=c++11 -Wno-c++14-compat -fno-exceptions -pedantic-errors" AC_CACHE_CHECK([whether $CC is Clang], [nl_cv_clang], diff --git a/tests/fuzz/fuzzer_platform.cpp b/tests/fuzz/fuzzer_platform.cpp index 72ebfb56a..b21dfadbc 100644 --- a/tests/fuzz/fuzzer_platform.cpp +++ b/tests/fuzz/fuzzer_platform.cpp @@ -64,9 +64,9 @@ static AlarmState sAlarmMilli; static AlarmState sAlarmMicro; static uint32_t sRandomState = 1; static uint8_t sRadioTransmitPsdu[OT_RADIO_FRAME_MAX_SIZE]; -static otRadioFrame sRadioTransmitFrame = {.mPsdu = sRadioTransmitPsdu}; +static otRadioFrame sRadioTransmitFrame; static uint8_t sRadioAckPsdu[OT_RADIO_FRAME_MAX_SIZE]; -static otRadioFrame sRadioAckFrame = {.mPsdu = sRadioAckPsdu}; +static otRadioFrame sRadioAckFrame; static bool sResetWasRequested = false; static otRadioState sRadioState = OT_RADIO_STATE_DISABLED; @@ -86,6 +86,9 @@ void FuzzerPlatformInit(void) sAlarmNow = 0; memset(&sAlarmMilli, 0, sizeof(sAlarmMilli)); memset(&sAlarmMicro, 0, sizeof(sAlarmMicro)); + + sRadioTransmitFrame.mPsdu = sRadioTransmitPsdu; + sRadioAckFrame.mPsdu = sRadioAckPsdu; } void FuzzerPlatformProcess(otInstance *aInstance)