reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 9e5fc9bf08e3dcac508fb4d49e9d00445f7d63ea
parent 69e2e465fff42fc416ee38cead2b6a94fb66c81c
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Sat, 28 Jul 2018 12:44:04 -0400

use C++17's std::size instead of a custom macro or function

interesting read: https://www.g-truc.net/post-0708.html

Diffstat:
MREADME.md | 2+-
MTupfile | 2+-
Mlinux.tup | 2+-
Mmacosx.tup | 8+++++---
Msrc/filedialog.cpp | 2+-
Msrc/main.cpp | 2+-
Msrc/win32.cpp | 6+++---
Msrc/win32.hpp | 2--
8 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/README.md b/README.md @@ -9,7 +9,7 @@ and the user guide. The following section describes how to build ReaPack on your computer. The build system uses Rake and is based on [Tup](http://gittup.org/tup/). -A modern compiler (gcc/clang/msvc) with C++14 support is needed. +A modern compiler (gcc/clang/msvc) with C++17 support is needed. By default the `rake` command triggers both the 64-bit and 32-bit builds and runs the test suite. Use `rake 'default[x64]'` or `rake 'default[x86]'` diff --git a/Tupfile b/Tupfile @@ -14,5 +14,5 @@ include @(TUP_PLATFORM).tup : foreach $(WDLSOURCE) |> !build $(WDLFLAGS) |> build/wdl_%B.o : build/*.o | $(LINKDEPS) |> !link $(SOFLAGS) |> $(SOTARGET) -: foreach test/*.cpp |> !build -Isrc $(SRCFLAGS) |> build/test/%B.o +: foreach test/*.cpp |> !build -Isrc $(SRCFLAGS) $(TSTFLAGS) |> build/test/%B.o : build/*.o build/test/*.o | $(LINKDEPS) |> !link $(TSFLAGS) |> $(TSTARGET) diff --git a/linux.tup b/linux.tup @@ -6,7 +6,7 @@ CXXFLAGS := -Wall -Wextra -Werror CXXFLAGS += -Wno-unused-parameter -Wno-missing-field-initializers CXXFLAGS += -Wno-unused-function -Wno-missing-braces CXXFLAGS += -fdiagnostics-color -fstack-protector-strong -fvisibility=hidden -CXXFLAGS += -pipe -fPIC -O2 -std=c++14 -m@(SUFFIX) +CXXFLAGS += -pipe -fPIC -O2 -std=c++17 -m@(SUFFIX) CXXFLAGS += -Ivendor -Ivendor/WDL -Ivendor/WDL/WDL -Ivendor/WDL/WDL/swell CXXFLAGS += -DWDL_NO_DEFINE_MINMAX -DSWELL_PROVIDED_BY_APP -DSWELL_TARGET_GDK CXXFLAGS += -DREAPACK_FILE=\"$(REAPACK_FILE)\" diff --git a/macosx.tup b/macosx.tup @@ -6,15 +6,17 @@ CXXFLAGS := -Wall -Wextra -Werror CXXFLAGS += -Wno-unused-parameter -Wno-missing-field-initializers CXXFLAGS += -Wno-unused-function -Wno-unused-private-field -Wno-missing-braces CXXFLAGS += -fdiagnostics-color -fstack-protector-strong -fvisibility=hidden -CXXFLAGS += -pipe -fPIC -O2 -CXXFLAGS += -arch @(ARCH) -mmacosx-version-min=10.7 +CXXFLAGS += -pipe -fPIC -O2 -arch @(ARCH) -mmacosx-version-min=10.7 CXXFLAGS += -Ivendor -Ivendor/WDL -Ivendor/WDL/WDL -Ivendor/WDL/WDL/swell CXXFLAGS += -DWDL_NO_DEFINE_MINMAX -DSWELL_APP_PREFIX=SWELL_REAPACK CXXFLAGS += -DREAPACK_FILE=\"$(REAPACK_FILE)\" -SRCFLAGS := -std=c++14 -stdlib=libc++ +SRCFLAGS := -std=c++17 -stdlib=libc++ WDLFLAGS := -w +# std::uncaught_exceptions is unavailable prior to macOS 10.12 +TSTFLAGS := -DCATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS + SWELL := $(WDL)/swell WDLSOURCE += $(SWELL)/swell.cpp $(SWELL)/swell-ini.cpp $(SWELL)/swell-miscdlg.mm WDLSOURCE += $(SWELL)/swell-gdi.mm $(SWELL)/swell-kb.mm $(SWELL)/swell-menu.mm diff --git a/src/filedialog.cpp b/src/filedialog.cpp @@ -39,7 +39,7 @@ static string getFileName(BOOL(__stdcall *func)(LPOPENFILENAME), OPENFILENAME of{sizeof(OPENFILENAME), parent, instance}; of.lpstrFilter = filters; of.lpstrFile = pathBuffer; - of.nMaxFile = lengthof(pathBuffer); + of.nMaxFile = static_cast<DWORD>(size(pathBuffer)); of.lpstrInitialDir = wideInitialDir.c_str(); of.lpstrTitle = wideTitle.c_str(); of.Flags = OFN_HIDEREADONLY | OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT; diff --git a/src/main.cpp b/src/main.cpp @@ -106,7 +106,7 @@ static bool checkLocation(REAPER_PLUGIN_HINSTANCE module) #ifdef _WIN32 Win32::char_type self[MAX_PATH] = {}; - GetModuleFileName(module, self, lengthof(self)); + GetModuleFileName(module, self, static_cast<DWORD>(size(self))); Path current(Win32::narrow(self)); #else Dl_info info{}; diff --git a/src/win32.cpp b/src/win32.cpp @@ -58,7 +58,7 @@ int Win32::messageBox(const HWND handle, const char *text, string Win32::getWindowText(const HWND handle) { char_type buffer[4096]; - GetWindowText(handle, buffer, (int)lengthof(buffer)); + GetWindowText(handle, buffer, static_cast<int>(size(buffer))); return narrow(buffer); } @@ -98,8 +98,8 @@ string Win32::getPrivateProfileString(const char *group, const char *key, const char *fallback, const char *path) { char_type buffer[4096]; - GetPrivateProfileString(widen_cstr(group), widen_cstr(key), - widen_cstr(fallback), buffer, lengthof(buffer), widen_cstr(path)); + GetPrivateProfileString(widen_cstr(group), widen_cstr(key), widen_cstr(fallback), + buffer, static_cast<DWORD>(size(buffer)), widen_cstr(path)); return narrow(buffer); } diff --git a/src/win32.hpp b/src/win32.hpp @@ -30,8 +30,6 @@ # include <swell-types.h> #endif -#define lengthof(t) (sizeof(t) / sizeof(*t)) - namespace Win32 { #ifdef _WIN32 typedef wchar_t char_type;