From bca384e6916671a84140adeb5cb0b57617d911f8 Mon Sep 17 00:00:00 2001 From: anders_k Date: Sat, 2 Jun 2018 00:38:45 +0000 Subject: [PATCH] throw() is deprecated in C++17 git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7000 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/Platform.h | 11 ++++++++--- Source/scriptpp.cpp | 4 ++-- Source/util.cpp | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Source/Platform.h b/Source/Platform.h index 0c972474..341367a0 100644 --- a/Source/Platform.h +++ b/Source/Platform.h @@ -1037,9 +1037,14 @@ typedef struct tagVS_FIXEDFILEINFO { #if defined(__clang__) && defined(__cplusplus) && __cplusplus < 201103L -#define NSIS_CXX_THROWSPEC(throwspec) throw(throwspec) // Use exception specifications to avoid operator new missing-exception-spec warning +# define NSIS_CXX_THROWSPEC(throwspec) throw(throwspec) // Use exception specifications to avoid operator new missing-exception-spec warning #else -#define NSIS_CXX_THROWSPEC(ignoredthrowspec) // Ignore c++ exception specifications +# define NSIS_CXX_THROWSPEC(ignoredthrowspec) // Ignore c++ exception specifications +#endif +#if defined(__cplusplus) && __cplusplus >= 201103L +# define NSIS_CXX_NOEXCEPT() noexcept(true) +#else +# define NSIS_CXX_NOEXCEPT() throw() // Can't specialize __declspec(nothrow) because MSVC requires it before the function name #endif #define BUGBUG64TRUNCATE(cast,xpr) ( (cast) (xpr) ) @@ -1048,7 +1053,7 @@ _tprintf on Windows/MSVCRT treats %s as TCHAR* and on POSIX %s is always char*! Always use our NPRI* (NsisPRInt*[Narrow|Wide]) defines in format strings when calling functions from tchar.h (Similar to the way works) -Example: _tprintf(_T("Hello %") NPRIs _T("\n"), _T("World")); +Example: _tprintf(_T("%") NPRIs _T(" %") NPRIws _T("\n"), _T("Hello"), L"World"); */ #ifdef _WIN32 # define NPRIs _T("s") diff --git a/Source/scriptpp.cpp b/Source/scriptpp.cpp index b20e6fd8..ccb0df9c 100644 --- a/Source/scriptpp.cpp +++ b/Source/scriptpp.cpp @@ -235,11 +235,11 @@ void CEXEBuild::del_date_time_predefines() TCHAR* CEXEBuild::GetMacro(const TCHAR *macroname, TCHAR**macroend /*= 0*/) { TCHAR *t = (TCHAR*)m_macros.get(), *mbeg, *mbufbeg = t; - size_t cbAll = m_macros.getlen(), cchAll = cbAll / sizeof(TCHAR); + size_t cbAll = m_macros.getlen(); for (; t && *t; ++t) { mbeg = t; - if (t-mbufbeg >= cchAll) break; + if ((size_t)t - (size_t)mbufbeg >= cbAll) break; const bool foundit = !_tcsicmp(mbeg, macroname); t += _tcslen(t) + 1; // advance over macro name diff --git a/Source/util.cpp b/Source/util.cpp index 14fcb344..ad1b444c 100644 --- a/Source/util.cpp +++ b/Source/util.cpp @@ -1354,5 +1354,5 @@ void *operator new[](size_t size) NSIS_CXX_THROWSPEC(bad_alloc) { return operator new(size); } -void operator delete(void *p) throw() { if (p) free(p); } -void operator delete [](void *p) throw() { if (p) free(p); } +void operator delete(void *p) NSIS_CXX_NOEXCEPT() { if (p) free(p); } +void operator delete [](void *p) NSIS_CXX_NOEXCEPT() { if (p) free(p); }