Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Made SDL_RectEmpty and SDL_RectEquals macros into SDL_FORCE_INLINE fu…
Browse files Browse the repository at this point in the history
…nctions.

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".
  • Loading branch information
icculus committed May 16, 2013
1 parent 805b381 commit dd18e77
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions include/SDL_rect.h
Expand Up @@ -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.
Expand Down

0 comments on commit dd18e77

Please sign in to comment.