From 9a863ce3fbd29c9c2ffbd53ae74f32d28cbff464 Mon Sep 17 00:00:00 2001 From: Christoph Niethammer Date: Wed, 11 Dec 2024 13:41:09 +0100 Subject: [PATCH] Remove mardy_assert from OptionParser to prevent initialisation order issues MarDyn_assert uses the logger infrastructure of ls1 internally. However the logger is initialized with command line options causing a circular dependence. Therefore, remove mardyn_assert from the OptionParser. If something is wrong with the command line it is early in the execution and therefore no need for the extensive logger infrastructure to be used. Signed-off-by: Christoph Niethammer --- src/utils/OptionParser.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/utils/OptionParser.cpp b/src/utils/OptionParser.cpp index 72ae9273d2..c5e2c64e1f 100644 --- a/src/utils/OptionParser.cpp +++ b/src/utils/OptionParser.cpp @@ -7,11 +7,10 @@ #include "OptionParser.h" -#include "utils/mardyn_assert.h" - -#include #include #include +#include +#include #include #ifdef ENABLE_MPI @@ -448,15 +447,13 @@ void OptionParser::print_version() const { } void OptionParser::exit() const { - std::ostringstream error_message; - error_message << "OptionParser::exit() called" << std::endl; - MARDYN_EXIT(error_message.str()); + std::cerr << "OptionParser::exit() called" << std::endl; + std::exit(1); } void OptionParser::error(const std::string& msg) const { + std::cerr << "Optionparser error: " << msg << std::endl; print_usage(std::cerr); - std::ostringstream error_message; - error_message << prog() << ": " << _("error") << ": " << msg << std::endl; - MARDYN_EXIT(error_message.str()); + std::exit(1); } ////////// } class OptionParser //////////