From ec3c8e7701ed86c6d56bfaf58cb1fbb1e52e54e0 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 22 Aug 2021 11:35:08 +0200 Subject: [PATCH] Handle THROW macro in its own scope. --- CMakeLists.txt | 7 ++++++- src/Exception.hpp | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f3083f..907b301 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,12 @@ project(Arbutils) add_compile_options(-Wall -Wextra -Werror) # We like new stuff, so set the c++ standard to c++20. set(CMAKE_CXX_STANDARD 20) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +if (NOT WINDOWS) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) +else() + set(CMAKE_POSITION_INDEPENDENT_CODE OFF) +endif() option(WINDOWS "Whether the build target is Windows or not." OFF) option(SHARED "Whether we should build a shared library, instead of a static one." OFF) diff --git a/src/Exception.hpp b/src/Exception.hpp index 1c3c561..e78c07e 100644 --- a/src/Exception.hpp +++ b/src/Exception.hpp @@ -152,9 +152,11 @@ static consteval const char* file_name(const char* path) { } #define THROW(message) \ - std::stringstream ___ss; \ - ___ss << "[" << file_name(__FILE__) << ":" << __LINE__ << "] " << message; \ - throw ArbUt::Exception(___ss.str()); + { \ + std::stringstream ___ss; \ + ___ss << "[" << file_name(__FILE__) << ":" << __LINE__ << "] " << message; \ + throw ArbUt::Exception(___ss.str()); \ + } #define NOT_REACHABLE THROW("Not reachable"); #define NOT_IMPLEMENTED THROW("Not implemented");