From cd4052879a04da2c0bc5b9c597a5eb257bb7067a Mon Sep 17 00:00:00 2001 From: fwcd Date: Fri, 8 Mar 2019 15:43:52 +0100 Subject: [PATCH] Include in calc.cpp to resolve the missing std::make_unique calls and bump C++ standard to 14 Change DEFAULT_GPR_STR and DEFAULT_NUMBER_STR in calc.cpp to be const (and not constexpr) since 'length' is not a constexpr function according to Clang BYTE and ARRAYSIZE macro Replace constexpr declarations in scidisp.cpp with const since char_traits::length is not a constexpr function in Clang Define SCODE_CODE in winerror_cross_platform.h Add #pragma once and included in EngineStrings.h Include in CalcEngine.h --- CMakeLists.txt | 2 +- src/CalcManager/CEngine/calc.cpp | 8 +++++--- src/CalcManager/CEngine/scidisp.cpp | 4 ++-- src/CalcManager/Header Files/CalcEngine.h | 2 ++ src/CalcManager/Header Files/EngineStrings.h | 5 +++++ src/CalcManager/win_data_types_cross_platform.h | 3 +++ src/CalcManager/winerror_cross_platform.h | 1 + 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2728e702..db306038 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.6) project(calculator) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 14) add_subdirectory(src) diff --git a/src/CalcManager/CEngine/calc.cpp b/src/CalcManager/CEngine/calc.cpp index 92a551e2..74456c4f 100644 --- a/src/CalcManager/CEngine/calc.cpp +++ b/src/CalcManager/CEngine/calc.cpp @@ -8,9 +8,11 @@ #endif #include "Header Files/CalcEngine.h" - #include "CalculatorResource.h" +#include +#include + using namespace std; using namespace CalcEngine; @@ -24,8 +26,8 @@ static constexpr int32_t DEFAULT_RADIX = 10; static constexpr wchar_t DEFAULT_DEC_SEPARATOR = L'.'; static constexpr wchar_t DEFAULT_GRP_SEPARATOR = L','; -static constexpr wstring_view DEFAULT_GRP_STR = L"3;0"; -static constexpr wstring_view DEFAULT_NUMBER_STR = L"0"; +static const wstring_view DEFAULT_GRP_STR = L"3;0"; +static const wstring_view DEFAULT_NUMBER_STR = L"0"; // Read strings for keys, errors, trig types, etc. // These will be copied from the resources to local memory. diff --git a/src/CalcManager/CEngine/scidisp.cpp b/src/CalcManager/CEngine/scidisp.cpp index de4fd715..a8c9b3ef 100644 --- a/src/CalcManager/CEngine/scidisp.cpp +++ b/src/CalcManager/CEngine/scidisp.cpp @@ -26,8 +26,8 @@ using namespace CalcEngine; constexpr int MAX_EXPONENT = 4; constexpr uint32_t MAX_GROUPING_SIZE = 16; -constexpr wstring_view c_decPreSepStr = L"[+-]?(\\d*)["; -constexpr wstring_view c_decPostSepStr = L"]?(\\d*)(?:e[+-]?(\\d*))?$"; +const wstring_view c_decPreSepStr = L"[+-]?(\\d*)["; +const wstring_view c_decPostSepStr = L"]?(\\d*)(?:e[+-]?(\\d*))?$"; /****************************************************************************\ diff --git a/src/CalcManager/Header Files/CalcEngine.h b/src/CalcManager/Header Files/CalcEngine.h index 48597f1c..d44a1b8c 100644 --- a/src/CalcManager/Header Files/CalcEngine.h +++ b/src/CalcManager/Header Files/CalcEngine.h @@ -32,6 +32,8 @@ #include "Rational.h" #include "RationalMath.h" +#include + // The following are NOT real exports of CalcEngine, but for forward declarations // The real exports follows later diff --git a/src/CalcManager/Header Files/EngineStrings.h b/src/CalcManager/Header Files/EngineStrings.h index 2ada6bba..2e58c283 100644 --- a/src/CalcManager/Header Files/EngineStrings.h +++ b/src/CalcManager/Header Files/EngineStrings.h @@ -13,6 +13,11 @@ * Created: 13-Feb-2008 * \****************************************************************************/ + +#pragma once + +#include + #define IDS_FIRSTENGSTR IDS_ENGINESTR_FIRST #define IDS_DECIMAL 4 diff --git a/src/CalcManager/win_data_types_cross_platform.h b/src/CalcManager/win_data_types_cross_platform.h index daa99bd6..b4178a83 100644 --- a/src/CalcManager/win_data_types_cross_platform.h +++ b/src/CalcManager/win_data_types_cross_platform.h @@ -6,6 +6,7 @@ typedef uint64_t ULONGLONG; typedef int INT; typedef char CHAR; typedef long LONG; +typedef unsigned char BYTE; typedef unsigned int UINT_PTR; typedef unsigned long ULONG_PTR; typedef unsigned int ULONG32; @@ -21,3 +22,5 @@ typedef ULONG_PTR DWORD_PTR; #define HIWORD(dw) ((WORD)((((DWORD_PTR)(dw)) >> 16) & 0xffff)) #define LODWORD(qw) ((DWORD)(qw)) #define HIDWORD(qw) ((DWORD)(((qw) >> 32) & 0xffffffff)) + +#define ARRAYSIZE(a) (sizeof(a) / sizeof(*a)) diff --git a/src/CalcManager/winerror_cross_platform.h b/src/CalcManager/winerror_cross_platform.h index 6961e77f..4c6730c0 100644 --- a/src/CalcManager/winerror_cross_platform.h +++ b/src/CalcManager/winerror_cross_platform.h @@ -16,3 +16,4 @@ typedef int32_t HRESULT; #define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) #define FAILED(hr) (((HRESULT)(hr)) < 0) +#define SCODE_CODE(sc) ((sc) & 0xFFFF)