diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c413de5..307c0fb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.8) project(calculator CXX) set(CMAKE_CXX_STANDARD 17) diff --git a/src/CalcManager/CEngine/Number.cpp b/src/CalcManager/CEngine/Number.cpp index b445fed2..4bf83a33 100644 --- a/src/CalcManager/CEngine/Number.cpp +++ b/src/CalcManager/CEngine/Number.cpp @@ -59,13 +59,6 @@ namespace CalcEngine bool Number::IsZero() const { - for (auto const& digit : Mantissa()) - { - if (digit != 0) - { - return false; - } - } - return true; + return all_of(m_mantissa.begin(), m_mantissa.end(), [](auto &&i) { return i == 0; }); } } diff --git a/src/CalcManager/CEngine/calc.cpp b/src/CalcManager/CEngine/calc.cpp index 00fa2b45..210b2023 100644 --- a/src/CalcManager/CEngine/calc.cpp +++ b/src/CalcManager/CEngine/calc.cpp @@ -18,8 +18,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 const wstring_view DEFAULT_GRP_STR = L"3;0"; -static const wstring_view DEFAULT_NUMBER_STR = L"0"; +static constexpr wstring_view DEFAULT_GRP_STR = L"3;0"; +static constexpr 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 e099b3b4..64af7593 100644 --- a/src/CalcManager/CEngine/scidisp.cpp +++ b/src/CalcManager/CEngine/scidisp.cpp @@ -21,8 +21,8 @@ using namespace CalcEngine; constexpr int MAX_EXPONENT = 4; constexpr uint32_t MAX_GROUPING_SIZE = 16; -const wstring_view c_decPreSepStr = L"[+-]?(\\d*)["; -const wstring_view c_decPostSepStr = L"]?(\\d*)(?:e[+-]?(\\d*))?$"; +constexpr wstring_view c_decPreSepStr = L"[+-]?(\\d*)["; +constexpr wstring_view c_decPostSepStr = L"]?(\\d*)(?:e[+-]?(\\d*))?$"; /****************************************************************************\ diff --git a/src/CalcManager/Header Files/EngineStrings.h b/src/CalcManager/Header Files/EngineStrings.h index 2e58c283..d358766d 100644 --- a/src/CalcManager/Header Files/EngineStrings.h +++ b/src/CalcManager/Header Files/EngineStrings.h @@ -219,7 +219,7 @@ #define SIDS_ERR_INPUT_OVERFLOW L"119" #define SIDS_ERR_OUTPUT_OVERFLOW L"120" -__declspec(selectany) std::wstring g_sids[] = +DECLSPEC_SELECTANY std::wstring g_sids[] = { std::wstring(SIDS_PLUS_MINUS), std::wstring(SIDS_C), diff --git a/src/CalcManager/pch.h b/src/CalcManager/pch.h index 843e8a01..6073de5a 100644 --- a/src/CalcManager/pch.h +++ b/src/CalcManager/pch.h @@ -25,7 +25,7 @@ #include #include -#ifdef _WIN32 +#if defined(_WIN32) && defined(_MSC_VER) #include #include @@ -41,4 +41,10 @@ #include "win_data_types_cross_platform.h" #include "sal_cross_platform.h" +#ifdef __GNUC__ +#define DECLSPEC_SELECTANY __attribute__((selectany)) +#else +#define DECLSPEC_SELECTANY __declspec(selectany) +#endif + #endif diff --git a/src/CalcManager/sal_cross_platform.h b/src/CalcManager/sal_cross_platform.h index cc650f17..c89e37d4 100644 --- a/src/CalcManager/sal_cross_platform.h +++ b/src/CalcManager/sal_cross_platform.h @@ -8,3 +8,4 @@ #define _Out_ #define _Inout_ #define __in_opt +#define _Frees_ptr_opt_