From da8a1bb74faa4d241ba874bc147e309591679d18 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 16 May 2013 12:16:12 -0400 Subject: [PATCH] Made SDL_RectEmpty and SDL_RectEquals macros into SDL_FORCE_INLINE functions. Fixes compiler warnings for things like this... if (SDL_RectEmpty(&rect)) {} ...where the macro turned into "if ( (!(&rect)) && etc )" which some compilers thought might be a programmer mistake, as "&rect" is always "true". --- include/SDL_rect.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/SDL_rect.h b/include/SDL_rect.h index a509c7004..26621a50c 100644 --- a/include/SDL_rect.h +++ b/include/SDL_rect.h @@ -71,14 +71,19 @@ typedef struct SDL_Rect /** * \brief Returns true if the rectangle has no area. */ -#define SDL_RectEmpty(X) ((!(X)) || ((X)->w <= 0) || ((X)->h <= 0)) +SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r) +{ + return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE; +} /** * \brief Returns true if the two rectangles are equal. */ -#define SDL_RectEquals(A, B) (((A)) && ((B)) && \ - ((A)->x == (B)->x) && ((A)->y == (B)->y) && \ - ((A)->w == (B)->w) && ((A)->h == (B)->h)) +SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b) +{ + return (a && b && (a->x == b->x) && (a->y == b->y) && + (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE; +} /** * \brief Determine whether two rectangles intersect.