From e7979589eee400eb9370de093977c9b31a8cac7e Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Sat, 13 Nov 2021 19:14:02 +0100 Subject: [PATCH] Removed -pthread and -fno-strict-aliasing flags --- Makefile | 2 +- throw.cpp | 38 +++++++++++++++++++++++++------------- throw.hpp | 4 ++-- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 46d1ed8..182ed3d 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ HDRS := $(filter-out $(LIBNAME).hpp,$(wildcard *.hpp)) CXX ?= g++ -CXXFLAGS := $(CXXFLAGS) -Wshadow -Wall -Wpedantic -Wextra -g -fno-strict-aliasing -std=c++17 -fPIC +CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -g -std=c++17 -fPIC ifeq ($(DEBUG),1) CXXFLAGS += -D DEBUG -O0 else diff --git a/throw.cpp b/throw.cpp index 451e81d..63b2e46 100644 --- a/throw.cpp +++ b/throw.cpp @@ -11,7 +11,10 @@ using namespace std; -static string combine_message_elements(const char* file, unsigned int line, const char* user_message, const char* sys_message) +static string combine_message_elements(const char* file, + unsigned int line, + const char* user_message, + const char* sys_message) { ostringstream msg; string f {file}; @@ -22,32 +25,41 @@ static string combine_message_elements(const char* file, unsigned int line, cons return msg.str(); } -void __throw_if_min1(int x, const char* file, unsigned int line, const char* message) +void __throw_if_min1(int x, + const char* file, + unsigned int line, + const char* message) { if (x == -1) { error_code ec {errno, system_category()}; ostringstream ec_str; ec_str << "system error " << ec.value() << ": " << ec.message(); string msg {combine_message_elements(file, line, message, ec_str.str().c_str())}; - throw system_error {ec, msg}; + throw system_error {ec, msg}; } } -void __throw_if_null(const void* p, const char* file, unsigned int line, const char* message) +void __throw_if_null(const void* p, + const char* file, + unsigned int line, + const char* message) { if (p == nullptr) { string msg {combine_message_elements(file, line, message, "null pointer exception")}; - throw runtime_error {msg}; + throw runtime_error {msg}; } } -void __throw_if_err(int err, const char* file, unsigned int line, const char* message) +void __throw_if_err(int err, + const char* file, + unsigned int line, + const char* message) { - if (err != 0) { - error_code ec {err, system_category()}; - ostringstream ec_str; - ec_str << "error " << err; - string msg {combine_message_elements(file, line, message, ec_str.str().c_str())}; - throw system_error {ec, msg}; - } + if (err != 0) { + error_code ec {err, system_category()}; + ostringstream ec_str; + ec_str << "error " << err; + string msg {combine_message_elements(file, line, message, ec_str.str().c_str())}; + throw system_error {ec, msg}; + } } diff --git a/throw.hpp b/throw.hpp index 06802b6..c34a016 100644 --- a/throw.hpp +++ b/throw.hpp @@ -1,6 +1,6 @@ // throw macros for OS X and other POSIX systems // adapted for Windows as well, november 2014 -// copyright © 2002-2014 Bob Polis +// copyright © 2002-2022 Bob Polis #ifndef __throw__ #define __throw__ @@ -16,6 +16,6 @@ void __throw_if_err(int err, const char* file, unsigned int line, const char* me #define throw_if_min1_msg(___x___, ___msg___) __throw_if_min1((___x___), __FILE__, __LINE__, ___msg___) #define throw_if_null_msg(__ptr__, ___msg___) __throw_if_null((__ptr__), __FILE__, __LINE__, ___msg___) -#define throw_if_err_msg(__err__, ___msg___) __throw_if_err((__err__), __FILE__, __LINE__, ___msg___) +#define throw_if_err_msg(__err__, ___msg___) __throw_if_err((__err__), __FILE__, __LINE__, ___msg___) #endif /* defined(__throw__) */