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