Made SDL_RectEmpty and SDL_RectEquals macros into SDL_FORCE_INLINE functions.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 16 May 2013 12:16:12 -0400
changeset 71854e201413e282
parent 7184 1615a5e23078
child 7186 94eb9dbd17b2
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
     1.1 --- a/include/SDL_rect.h	Thu May 16 01:03:28 2013 -0700
     1.2 +++ b/include/SDL_rect.h	Thu May 16 12:16:12 2013 -0400
     1.3 @@ -71,14 +71,19 @@
     1.4  /**
     1.5   *  \brief Returns true if the rectangle has no area.
     1.6   */
     1.7 -#define SDL_RectEmpty(X)    ((!(X)) || ((X)->w <= 0) || ((X)->h <= 0))
     1.8 +SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r)
     1.9 +{
    1.10 +    return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE;
    1.11 +}
    1.12  
    1.13  /**
    1.14   *  \brief Returns true if the two rectangles are equal.
    1.15   */
    1.16 -#define SDL_RectEquals(A, B)   (((A)) && ((B)) && \
    1.17 -                                ((A)->x == (B)->x) && ((A)->y == (B)->y) && \
    1.18 -                                ((A)->w == (B)->w) && ((A)->h == (B)->h))
    1.19 +SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b)
    1.20 +{
    1.21 +    return (a && b && (a->x == b->x) && (a->y == b->y) &&
    1.22 +            (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE;
    1.23 +}
    1.24  
    1.25  /**
    1.26   *  \brief Determine whether two rectangles intersect.