include/SDL_version.h
 author Sam Lantinga Mon, 08 Dec 2008 00:27:32 +0000 changeset 2859 99210400e8b9 parent 1895 c121d94672cb child 2982 b64c1d23039b permissions -rw-r--r--
     1 /*

     2     SDL - Simple DirectMedia Layer

     3     Copyright (C) 1997-2009 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

    34 #include "begin_code.h"

    35 /* Set up for C function definitions, even when using C++ */

    36 #ifdef __cplusplus

    37 /* *INDENT-OFF* */

    38 extern "C" {

    39 /* *INDENT-ON* */

    40 #endif

    41

    42 /**

    43  * \struct SDL_version

    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  * \def SDL_VERSION(x)

    70  * \brief Macro to determine SDL version program was compiled against.

    71  *

    72  * This macro fills in a SDL_version structure with the version of the

    73  *  library you compiled against. This is determined by what header the

    74  *  compiler uses. Note that if you dynamically linked the library, you might

    75  *  have a slightly newer or older version at runtime. That version can be

    76  *  determined with SDL_GetVersion(), which, unlike SDL_VERSION,

    77  *  is not a macro.

    78  *

    79  * \param x A pointer to a SDL_version struct to initialize.

    80  *

    81  * \sa SDL_version

    82  * \sa SDL_GetVersion

    83  */

    84 #define SDL_VERSION(x)							\

    85 {									\

    86 	(x)->major = SDL_MAJOR_VERSION;					\

    87 	(x)->minor = SDL_MINOR_VERSION;					\

    88 	(x)->patch = SDL_PATCHLEVEL;					\

    89 }

    90

    91 /* This macro turns the version numbers into a numeric value:

    92    (1,2,3) -> (1203)

    93    This assumes that there will never be more than 100 patchlevels

    94 */

    95 #define SDL_VERSIONNUM(X, Y, Z)						\

    96 	((X)*1000 + (Y)*100 + (Z))

    97

    98 /* This is the version number macro for the current SDL version */

    99 #define SDL_COMPILEDVERSION \

   100 	SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)

   101

   102 /* This macro will evaluate to true if compiled with SDL at least X.Y.Z */

   103 #define SDL_VERSION_ATLEAST(X, Y, Z) \

   104 	(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))

   105

   106 /**

   107  * \fn void SDL_GetVersion(SDL_version *ver)

   108  * \brief Get the version of SDL that is linked against your program.

   109  *

   110  * If you are using a shared library (DLL) version of SDL, then it is

   111  *  possible that it will be different than the version you compiled against.

   112  *

   113  * This is a real function; the macro SDL_VERSION tells you what version

   114  *  of SDL you compiled against:

   115  *

   116  * \code

   117  * SDL_version compiled;

   118  * SDL_version linked;

   119  *

   120  * SDL_VERSION(&compiled);

   121  * SDL_GetVersion(&linked);

   122  * printf("We compiled against SDL version %d.%d.%d ...\n",

   123  *           compiled.major, compiled.minor, compiled.patch);

   124  * printf("But we linked against SDL version %d.%d.%d.\n",

   125  *           linked.major, linked.minor, linked.patch);

   126  * \endcode

   127  *

   128  * This function may be called safely at any time, even before SDL_Init().

   129  *

   130  * \sa SDL_VERSION

   131  */

   132 extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver);

   133

   134 /* Ends C function definitions when using C++ */

   135 #ifdef __cplusplus

   136 /* *INDENT-OFF* */

   137 }

   138 /* *INDENT-ON* */

   139 #endif

   140 #include "close_code.h"

   141

   142 #endif /* _SDL_version_h */

   143

   144 /* vi: set ts=4 sw=4 expandtab: */