From f0396f8e6bd64b83163210df7b7cbe957590e0d0 Mon Sep 17 00:00:00 2001 From: Alexander Hoischen Date: Mon, 11 Jun 2018 21:07:33 +0200 Subject: [PATCH] Fix Exceptions Always Being Printed This commit fixes the issue, that exception messages were always printed to cerr, regardless of SOL_PRINT_ERRORS setting. This also makes the inclusion of iostream completely optional, reducing binary sizes. Fixes #652. --- sol/state_handling.hpp | 2 +- sol/trampoline.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sol/state_handling.hpp b/sol/state_handling.hpp index bb0922f8..66cc515e 100644 --- a/sol/state_handling.hpp +++ b/sol/state_handling.hpp @@ -29,7 +29,7 @@ #include "function.hpp" #include "object.hpp" -#ifdef SOL_PRINT_ERRORS +#if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS #include #endif diff --git a/sol/trampoline.hpp b/sol/trampoline.hpp index 4041349d..cf1fe823 100644 --- a/sol/trampoline.hpp +++ b/sol/trampoline.hpp @@ -29,7 +29,7 @@ #include #include -#ifdef SOL_PRINT_ERRORS +#if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS #include #endif @@ -47,7 +47,7 @@ namespace sol { // must push at least 1 object on the stack inline int default_exception_handler(lua_State* L, optional, string_view what) { -#ifdef SOL_PRINT_ERRORS +#if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS std::cerr << "[sol2] An exception occurred: "; std::cerr.write(what.data(), what.size()); std::cerr << std::endl;