From a3d2d4bc3427094bcfd0276d99dd4335d6d5fd36 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 18 May 2020 19:23:22 +0200 Subject: [PATCH] Fixed macros for GCC --- SDLU/Util.hpp | 8 ++++++-- SDLU/graphics/RenderWindow.cpp | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/SDLU/Util.hpp b/SDLU/Util.hpp index 94e1e90..35732da 100644 --- a/SDLU/Util.hpp +++ b/SDLU/Util.hpp @@ -9,8 +9,12 @@ #define IS_NULLPTR( x ) (x == nullptr) -#define RETURN_IF_NULLPTR( x , v ) { if(IS_NULLPTR(x)) return v; } -#define RETURN_IF_NOT_NULLPTR( x , v ) { if(!IS_NULLPTR(x)) return v; } +// TODO: Find fix for this, the original doesnt compile under gcc +#define RETURN_IF_NULLPTR( x ) { if(IS_NULLPTR(x)) return; } +#define RETURN_IF_NOT_NULLPTR( x ) { if(!IS_NULLPTR(x)) return; } + +#define RETURN_IF_NULLPTR_ARG( x, v ) { if(IS_NULLPTR(x)) return v; } +#define RETURN_IF_NOT_NULLPTR_ARG( x, v ) { if(!IS_NULLPTR(x)) return v; } typedef uint8_t Uint8; typedef int8_t Int8; diff --git a/SDLU/graphics/RenderWindow.cpp b/SDLU/graphics/RenderWindow.cpp index c05e5cf..eb9c3fb 100644 --- a/SDLU/graphics/RenderWindow.cpp +++ b/SDLU/graphics/RenderWindow.cpp @@ -59,13 +59,13 @@ namespace sdlu bool RenderWindow::IsOpen() { - RETURN_IF_NULLPTR(m_pWindow, false); + RETURN_IF_NULLPTR_ARG(m_pWindow, false); return (!SDL_GetWindowID(m_pWindow) ? false : true); } bool RenderWindow::PollEvent(SDL_Event* event) { - RETURN_IF_NULLPTR(m_pWindow, false); + RETURN_IF_NULLPTR_ARG(m_pWindow, false); // Handle events before the user in case a derived // class decides to block the event. while (SDL_PollEvent(event)) @@ -89,7 +89,7 @@ namespace sdlu Vector2i RenderWindow::GetPosition() { - RETURN_IF_NULLPTR(m_pWindow, Vector2i()); + RETURN_IF_NULLPTR_ARG(m_pWindow, Vector2i()); int x = 0, y = 0; SDL_GetWindowPosition(m_pWindow, &x, &y); @@ -112,7 +112,7 @@ namespace sdlu Vector2u RenderWindow::GetSize() { - RETURN_IF_NULLPTR(m_pWindow, Vector2u()); + RETURN_IF_NULLPTR_ARG(m_pWindow, Vector2u()); int x = 0, y = 0; SDL_GetWindowSize(m_pWindow, &x, &y); @@ -135,7 +135,7 @@ namespace sdlu std::string RenderWindow::GetTitle() { - RETURN_IF_NULLPTR(m_pWindow, ""); + RETURN_IF_NULLPTR_ARG(m_pWindow, ""); return SDL_GetWindowTitle(m_pWindow); }