From 064108c9c469b15b0ae0f5b958314ebd4d354019 Mon Sep 17 00:00:00 2001 From: Patryk Obara Date: Sat, 9 May 2020 21:07:02 +0200 Subject: [PATCH] Switch to using C++14 --- .clang-format | 13 +++---------- CONTRIBUTING.md | 6 +++--- README.md | 2 +- configure.ac | 4 ++-- include/byteorder.h | 2 +- include/compiler.h | 2 +- include/logging.h | 2 +- 7 files changed, 12 insertions(+), 19 deletions(-) diff --git a/.clang-format b/.clang-format index 4ef8b880..ff4614e5 100644 --- a/.clang-format +++ b/.clang-format @@ -25,7 +25,9 @@ ColumnLimit: 80 # C/C++ Language specifics # Language: Cpp -Standard: Cpp11 # in clang-format 11.x: c++11 +# in clang-format 9.x "Cpp11" covers formatting for C++11 and C++14 +# in clang-format 10.x: switch to "c++14" +Standard: Cpp11 # The extra indent or outdent of class access modifiers, e.g. public: # @@ -97,8 +99,6 @@ AlwaysBreakTemplateDeclarations: Yes # shortname = "dddd" # "eeee"; # -# TODO Test interaction with C++11 raw string literals -# # AlwaysBreakBeforeMultilineStrings: true # Attach braces to surrounding context except break before braces on function @@ -230,13 +230,6 @@ SpacesInParentheses: false # SpacesInSquareBrackets: false -# Insert a space after '{' and before '}' in struct initializers -# -# This is native C++11 style, but it looks very weird. -# TODO Investigate if it has any tangible benefits. -# -# Cpp11BracedListStyle: false - # A list of macros that should be interpreted as foreach loops instead of as # function calls. # diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dfbbc780..1d8126ee 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -93,15 +93,15 @@ Do not do mass reformating or renaming of existing code. ### Language -We use C-like C++11. To clarify: +We use C-like C++14. To clarify: - Avoid designing your code in complex object-oriented style. This does not mean "don't use classes", it means "don't use stuff like multiple inheritance, overblown class hierarchies, operator overloading, iostreams for stdout/stderr, etc, etc". -- C++11 has rich STL library, use it (responsibly - sometimes using +- C++14 has rich STL library, use it (responsibly - sometimes using C standard library makes more sense). -- Use C++11 features like `constexpr`, `static_assert`, managed pointers, +- Use modern C++ features like `constexpr`, `static_assert`, managed pointers, lambda expressions, for-each loops, etc. - Avoid using exceptions. C++ exceptions are trickier than you think. No, you won't get it right. Or person touching the code after you won't get diff --git a/README.md b/README.md index 80353f41..a1d19b8f 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ support today's systems. | | dosbox-staging | DOSBox |- |- |- | **Version control** | Git | [SVN] -| **Language** | C++11 | C++03[1] +| **Language** | C++14 | C++03[1] | **SDL** | 2.0 | 1.2 | **CI** | Yes | No | **Static analysis** | Yes[2],[3],[4] | No diff --git a/configure.ac b/configure.ac index 1f5a5e87..4e2acd4a 100644 --- a/configure.ac +++ b/configure.ac @@ -54,9 +54,9 @@ AC_CHECK_SIZEOF(unsigned long) AC_CHECK_SIZEOF(unsigned long long) AC_CHECK_SIZEOF(int *) -dnl Require compiler with C++11 support. +dnl Require compiler with C++14 support. dnl Allow GNU extensions to work around MinGW bugs around POSIX compatibility. -AX_CXX_COMPILE_STDCXX_11(ext, mandatory) +AX_CXX_COMPILE_STDCXX_14(ext, mandatory) dnl some semi complex check for sys/socket so it works on darwin as well AC_CHECK_HEADERS([stdlib.h sys/types.h]) diff --git a/include/byteorder.h b/include/byteorder.h index 600402cc..12d974da 100644 --- a/include/byteorder.h +++ b/include/byteorder.h @@ -40,7 +40,7 @@ #if !defined(_MSC_VER) -/* Aside of MSVC, every C++11-capable compiler provides __builtin_bswap* +/* Aside of MSVC, every C++14-capable compiler provides __builtin_bswap* * as compiler intrinsics or builtin functions. */ diff --git a/include/compiler.h b/include/compiler.h index 27ee04a8..7c6b3d4d 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -29,7 +29,7 @@ // The __attribute__ syntax is supported by GCC, Clang, and IBM compilers. // -// TODO: C++11 introduces standard syntax for implementation-defined attributes, +// TODO: C++11 introduced standard syntax for implementation-defined attributes, // it should allow for removal of C_HAS_ATTRIBUTE from the buildsystem. // However, the vast majority of GCC_ATTRIBUTEs in DOSBox code need // to be reviewed, as many of them seem to be incorrectly/unnecessarily diff --git a/include/logging.h b/include/logging.h index 0be4f1cc..88200c62 100644 --- a/include/logging.h +++ b/include/logging.h @@ -94,7 +94,7 @@ void GFX_ShowMsg(char const* format,...) GCC_ATTRIBUTE(__format__(__printf__, 1, // be redirected into internal DOSBox debugger for DOS programs (C_DEBUG feature). #define DEBUG_LOG_MSG(...) #else -// There's no portable way to expand variadic macro using C99/C++11 (or older) +// There's no portable way to expand variadic macro using C99/C++14 (or older) // alone. This language limitation got removed only with C++20 (through addition // of __VA_OPT__ macro). #ifdef _MSC_VER