include/SDL_version.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 29 Jul 2010 20:24:05 -0700
changeset 4627 3b5f4b3a69e1
parent 4419 5e7e1f1a4056
child 5262 b530ef003506
permissions -rw-r--r--
Documentation updates
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@3697
     3
    Copyright (C) 1997-2010 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@3407
    24
 *  \file SDL_version.h
slouken@3407
    25
 *  
slouken@3407
    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@2982
    33
#include "SDL_revision.h"
slouken@0
    34
slouken@0
    35
#include "begin_code.h"
slouken@0
    36
/* Set up for C function definitions, even when using C++ */
slouken@0
    37
#ifdef __cplusplus
slouken@1895
    38
/* *INDENT-OFF* */
slouken@0
    39
extern "C" {
slouken@1895
    40
/* *INDENT-ON* */
slouken@0
    41
#endif
slouken@0
    42
slouken@1895
    43
/**
slouken@3407
    44
 *  \brief Information the version of SDL in use.
slouken@3407
    45
 *  
slouken@3407
    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@3407
    51
 *  
slouken@3407
    52
 *  \sa SDL_VERSION
slouken@3407
    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@3407
    69
 *  \brief Macro to determine SDL version program was compiled against.
slouken@3407
    70
 *  
slouken@3407
    71
 *  This macro fills in a SDL_version structure with the version of the
slouken@1895
    72
 *  library you compiled against. This is determined by what header the
slouken@1895
    73
 *  compiler uses. Note that if you dynamically linked the library, you might
slouken@1895
    74
 *  have a slightly newer or older version at runtime. That version can be
slouken@3407
    75
 *  determined with SDL_GetVersion(), which, unlike SDL_VERSION(),
slouken@1895
    76
 *  is not a macro.
slouken@3407
    77
 *  
slouken@3407
    78
 *  \param x A pointer to a SDL_version struct to initialize.
slouken@3407
    79
 *  
slouken@3407
    80
 *  \sa SDL_version
slouken@3407
    81
 *  \sa SDL_GetVersion
slouken@0
    82
 */
slouken@1895
    83
#define SDL_VERSION(x)							\
slouken@0
    84
{									\
slouken@1895
    85
	(x)->major = SDL_MAJOR_VERSION;					\
slouken@1895
    86
	(x)->minor = SDL_MINOR_VERSION;					\
slouken@1895
    87
	(x)->patch = SDL_PATCHLEVEL;					\
slouken@0
    88
}
slouken@0
    89
slouken@3407
    90
/**
slouken@3407
    91
 *  This macro turns the version numbers into a numeric value:
slouken@3407
    92
 *  \verbatim
slouken@3407
    93
    (1,2,3) -> (1203)
slouken@3407
    94
    \endverbatim
slouken@3407
    95
 *  
slouken@3407
    96
 *  This assumes that there will never be more than 100 patchlevels.
slouken@3407
    97
 */
slouken@0
    98
#define SDL_VERSIONNUM(X, Y, Z)						\
icculus@1046
    99
	((X)*1000 + (Y)*100 + (Z))
slouken@0
   100
slouken@3407
   101
/**
slouken@3407
   102
 *  This is the version number macro for the current SDL version.
slouken@3407
   103
 */
slouken@0
   104
#define SDL_COMPILEDVERSION \
slouken@0
   105
	SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
slouken@0
   106
slouken@3407
   107
/**
slouken@3407
   108
 *  This macro will evaluate to true if compiled with SDL at least X.Y.Z.
slouken@3407
   109
 */
slouken@0
   110
#define SDL_VERSION_ATLEAST(X, Y, Z) \
slouken@0
   111
	(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
slouken@0
   112
slouken@1895
   113
/**
slouken@3407
   114
 *  \brief Get the version of SDL that is linked against your program.
slouken@1895
   115
 *
slouken@4627
   116
 *  If you are linking to SDL dynamically, then it is possible that the
slouken@4627
   117
 *  current version will be different than the version you compiled against.
slouken@4627
   118
 *  This function returns the current version, while SDL_VERSION() is a
slouken@4627
   119
 *  macro that tells you what version you compiled with.
slouken@3407
   120
 *  
slouken@3407
   121
 *  \code
slouken@3407
   122
 *  SDL_version compiled;
slouken@3407
   123
 *  SDL_version linked;
slouken@3407
   124
 *  
slouken@3407
   125
 *  SDL_VERSION(&compiled);
slouken@3407
   126
 *  SDL_GetVersion(&linked);
slouken@3407
   127
 *  printf("We compiled against SDL version %d.%d.%d ...\n",
slouken@3407
   128
 *         compiled.major, compiled.minor, compiled.patch);
slouken@3407
   129
 *  printf("But we linked against SDL version %d.%d.%d.\n",
slouken@3407
   130
 *         linked.major, linked.minor, linked.patch);
slouken@3407
   131
 *  \endcode
slouken@3407
   132
 *  
slouken@3407
   133
 *  This function may be called safely at any time, even before SDL_Init().
slouken@3407
   134
 *  
slouken@3407
   135
 *  \sa SDL_VERSION
slouken@0
   136
 */
slouken@1895
   137
extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver);
slouken@0
   138
slouken@2982
   139
/**
slouken@3407
   140
 *  \brief Get the code revision of SDL that is linked against your program.
icculus@4419
   141
 *
slouken@4627
   142
 *  Returns an arbitrary string (a hash value) uniquely identifying the
slouken@4627
   143
 *  exact revision of the SDL library in use, and is only useful in comparing
slouken@4627
   144
 *  against other revisions. It is NOT an incrementing number.
slouken@2982
   145
 */
icculus@4419
   146
extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
slouken@2982
   147
slouken@0
   148
/* Ends C function definitions when using C++ */
slouken@0
   149
#ifdef __cplusplus
slouken@1895
   150
/* *INDENT-OFF* */
slouken@0
   151
}
slouken@1895
   152
/* *INDENT-ON* */
slouken@0
   153
#endif
slouken@0
   154
#include "close_code.h"
slouken@0
   155
slouken@0
   156
#endif /* _SDL_version_h */
slouken@1895
   157
slouken@1895
   158
/* vi: set ts=4 sw=4 expandtab: */