include/SDL_version.h
author Ryan C. Gordon <icculus@icculus.org>
Sun, 28 Feb 2010 02:07:40 -0500
changeset 4419 5e7e1f1a4056
parent 3697 f7b03b6838cb
child 4627 3b5f4b3a69e1
permissions -rw-r--r--
Changed revision details to be a string (an hg changeset) instead of an int.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2010 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 
    23 /**
    24  *  \file SDL_version.h
    25  *  
    26  *  This header defines the current SDL version.
    27  */
    28 
    29 #ifndef _SDL_version_h
    30 #define _SDL_version_h
    31 
    32 #include "SDL_stdinc.h"
    33 #include "SDL_revision.h"
    34 
    35 #include "begin_code.h"
    36 /* Set up for C function definitions, even when using C++ */
    37 #ifdef __cplusplus
    38 /* *INDENT-OFF* */
    39 extern "C" {
    40 /* *INDENT-ON* */
    41 #endif
    42 
    43 /**
    44  *  \brief Information the version of SDL in use.
    45  *  
    46  *  Represents the library's version as three levels: major revision
    47  *  (increments with massive changes, additions, and enhancements),
    48  *  minor revision (increments with backwards-compatible changes to the
    49  *  major revision), and patchlevel (increments with fixes to the minor
    50  *  revision).
    51  *  
    52  *  \sa SDL_VERSION
    53  *  \sa SDL_GetVersion
    54  */
    55 typedef struct SDL_version
    56 {
    57     Uint8 major;        /**< major version */
    58     Uint8 minor;        /**< minor version */
    59     Uint8 patch;        /**< update version */
    60 } SDL_version;
    61 
    62 /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
    63 */
    64 #define SDL_MAJOR_VERSION	1
    65 #define SDL_MINOR_VERSION	3
    66 #define SDL_PATCHLEVEL		0
    67 
    68 /**
    69  *  \brief Macro to determine SDL version program was compiled against.
    70  *  
    71  *  This macro fills in a SDL_version structure with the version of the
    72  *  library you compiled against. This is determined by what header the
    73  *  compiler uses. Note that if you dynamically linked the library, you might
    74  *  have a slightly newer or older version at runtime. That version can be
    75  *  determined with SDL_GetVersion(), which, unlike SDL_VERSION(),
    76  *  is not a macro.
    77  *  
    78  *  \param x A pointer to a SDL_version struct to initialize.
    79  *  
    80  *  \sa SDL_version
    81  *  \sa SDL_GetVersion
    82  */
    83 #define SDL_VERSION(x)							\
    84 {									\
    85 	(x)->major = SDL_MAJOR_VERSION;					\
    86 	(x)->minor = SDL_MINOR_VERSION;					\
    87 	(x)->patch = SDL_PATCHLEVEL;					\
    88 }
    89 
    90 /**
    91  *  This macro turns the version numbers into a numeric value:
    92  *  \verbatim
    93     (1,2,3) -> (1203)
    94     \endverbatim
    95  *  
    96  *  This assumes that there will never be more than 100 patchlevels.
    97  */
    98 #define SDL_VERSIONNUM(X, Y, Z)						\
    99 	((X)*1000 + (Y)*100 + (Z))
   100 
   101 /**
   102  *  This is the version number macro for the current SDL version.
   103  */
   104 #define SDL_COMPILEDVERSION \
   105 	SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
   106 
   107 /**
   108  *  This macro will evaluate to true if compiled with SDL at least X.Y.Z.
   109  */
   110 #define SDL_VERSION_ATLEAST(X, Y, Z) \
   111 	(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
   112 
   113 /**
   114  *  \brief Get the version of SDL that is linked against your program.
   115  *  
   116  *  If you are using a shared library (DLL) version of SDL, then it is
   117  *  possible that it will be different than the version you compiled against.
   118  *
   119  *  This is a real function; the macro SDL_VERSION() tells you what version
   120  *  of SDL you compiled against:
   121  *  
   122  *  \code
   123  *  SDL_version compiled;
   124  *  SDL_version linked;
   125  *  
   126  *  SDL_VERSION(&compiled);
   127  *  SDL_GetVersion(&linked);
   128  *  printf("We compiled against SDL version %d.%d.%d ...\n",
   129  *         compiled.major, compiled.minor, compiled.patch);
   130  *  printf("But we linked against SDL version %d.%d.%d.\n",
   131  *         linked.major, linked.minor, linked.patch);
   132  *  \endcode
   133  *  
   134  *  This function may be called safely at any time, even before SDL_Init().
   135  *  
   136  *  \sa SDL_VERSION
   137  */
   138 extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver);
   139 
   140 /**
   141  *  \brief Get the code revision of SDL that is linked against your program.
   142  *
   143  *  This is an arbitrary string (a hash value, actually), and is only useful
   144  *  in comparing against other revisions. It is NOT an incrementing number.
   145  */
   146 extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
   147 
   148 /* Ends C function definitions when using C++ */
   149 #ifdef __cplusplus
   150 /* *INDENT-OFF* */
   151 }
   152 /* *INDENT-ON* */
   153 #endif
   154 #include "close_code.h"
   155 
   156 #endif /* _SDL_version_h */
   157 
   158 /* vi: set ts=4 sw=4 expandtab: */