include/SDL_version.h
author Sam Lantinga <slouken@libsdl.org>
Fri, 08 Apr 2011 13:03:26 -0700
changeset 5535 96594ac5fd1a
parent 5359 d5fe4ed3a28d
child 6138 4c64952a58fb
permissions -rw-r--r--
SDL 1.3 is now under the zlib license.
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@5535
     3
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
slouken@0
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@0
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@0
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@0
    20
*/
slouken@0
    21
slouken@1895
    22
/**
slouken@3407
    23
 *  \file SDL_version.h
slouken@3407
    24
 *  
slouken@3407
    25
 *  This header defines the current SDL version.
slouken@1895
    26
 */
slouken@0
    27
slouken@0
    28
#ifndef _SDL_version_h
slouken@0
    29
#define _SDL_version_h
slouken@0
    30
slouken@1356
    31
#include "SDL_stdinc.h"
slouken@0
    32
slouken@0
    33
#include "begin_code.h"
slouken@0
    34
/* Set up for C function definitions, even when using C++ */
slouken@0
    35
#ifdef __cplusplus
slouken@1895
    36
/* *INDENT-OFF* */
slouken@0
    37
extern "C" {
slouken@1895
    38
/* *INDENT-ON* */
slouken@0
    39
#endif
slouken@0
    40
slouken@1895
    41
/**
slouken@3407
    42
 *  \brief Information the version of SDL in use.
slouken@3407
    43
 *  
slouken@3407
    44
 *  Represents the library's version as three levels: major revision
slouken@1895
    45
 *  (increments with massive changes, additions, and enhancements),
slouken@1895
    46
 *  minor revision (increments with backwards-compatible changes to the
slouken@1895
    47
 *  major revision), and patchlevel (increments with fixes to the minor
slouken@1895
    48
 *  revision).
slouken@3407
    49
 *  
slouken@3407
    50
 *  \sa SDL_VERSION
slouken@3407
    51
 *  \sa SDL_GetVersion
slouken@1895
    52
 */
slouken@1895
    53
typedef struct SDL_version
slouken@1895
    54
{
slouken@1895
    55
    Uint8 major;        /**< major version */
slouken@1895
    56
    Uint8 minor;        /**< minor version */
slouken@1895
    57
    Uint8 patch;        /**< update version */
slouken@1895
    58
} SDL_version;
slouken@1895
    59
slouken@0
    60
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
slouken@0
    61
*/
slouken@0
    62
#define SDL_MAJOR_VERSION	1
slouken@1895
    63
#define SDL_MINOR_VERSION	3
slouken@1895
    64
#define SDL_PATCHLEVEL		0
slouken@0
    65
slouken@1895
    66
/**
slouken@3407
    67
 *  \brief Macro to determine SDL version program was compiled against.
slouken@3407
    68
 *  
slouken@3407
    69
 *  This macro fills in a SDL_version structure with the version of the
slouken@1895
    70
 *  library you compiled against. This is determined by what header the
slouken@1895
    71
 *  compiler uses. Note that if you dynamically linked the library, you might
slouken@1895
    72
 *  have a slightly newer or older version at runtime. That version can be
slouken@3407
    73
 *  determined with SDL_GetVersion(), which, unlike SDL_VERSION(),
slouken@1895
    74
 *  is not a macro.
slouken@3407
    75
 *  
slouken@3407
    76
 *  \param x A pointer to a SDL_version struct to initialize.
slouken@3407
    77
 *  
slouken@3407
    78
 *  \sa SDL_version
slouken@3407
    79
 *  \sa SDL_GetVersion
slouken@0
    80
 */
slouken@1895
    81
#define SDL_VERSION(x)							\
slouken@0
    82
{									\
slouken@1895
    83
	(x)->major = SDL_MAJOR_VERSION;					\
slouken@1895
    84
	(x)->minor = SDL_MINOR_VERSION;					\
slouken@1895
    85
	(x)->patch = SDL_PATCHLEVEL;					\
slouken@0
    86
}
slouken@0
    87
slouken@3407
    88
/**
slouken@3407
    89
 *  This macro turns the version numbers into a numeric value:
slouken@3407
    90
 *  \verbatim
slouken@3407
    91
    (1,2,3) -> (1203)
slouken@3407
    92
    \endverbatim
slouken@3407
    93
 *  
slouken@3407
    94
 *  This assumes that there will never be more than 100 patchlevels.
slouken@3407
    95
 */
slouken@0
    96
#define SDL_VERSIONNUM(X, Y, Z)						\
icculus@1046
    97
	((X)*1000 + (Y)*100 + (Z))
slouken@0
    98
slouken@3407
    99
/**
slouken@3407
   100
 *  This is the version number macro for the current SDL version.
slouken@3407
   101
 */
slouken@0
   102
#define SDL_COMPILEDVERSION \
slouken@0
   103
	SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
slouken@0
   104
slouken@3407
   105
/**
slouken@3407
   106
 *  This macro will evaluate to true if compiled with SDL at least X.Y.Z.
slouken@3407
   107
 */
slouken@0
   108
#define SDL_VERSION_ATLEAST(X, Y, Z) \
slouken@0
   109
	(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
slouken@0
   110
slouken@1895
   111
/**
slouken@3407
   112
 *  \brief Get the version of SDL that is linked against your program.
slouken@1895
   113
 *
slouken@4627
   114
 *  If you are linking to SDL dynamically, then it is possible that the
slouken@4627
   115
 *  current version will be different than the version you compiled against.
slouken@4627
   116
 *  This function returns the current version, while SDL_VERSION() is a
slouken@4627
   117
 *  macro that tells you what version you compiled with.
slouken@3407
   118
 *  
slouken@3407
   119
 *  \code
slouken@3407
   120
 *  SDL_version compiled;
slouken@3407
   121
 *  SDL_version linked;
slouken@3407
   122
 *  
slouken@3407
   123
 *  SDL_VERSION(&compiled);
slouken@3407
   124
 *  SDL_GetVersion(&linked);
slouken@3407
   125
 *  printf("We compiled against SDL version %d.%d.%d ...\n",
slouken@3407
   126
 *         compiled.major, compiled.minor, compiled.patch);
slouken@3407
   127
 *  printf("But we linked against SDL version %d.%d.%d.\n",
slouken@3407
   128
 *         linked.major, linked.minor, linked.patch);
slouken@3407
   129
 *  \endcode
slouken@3407
   130
 *  
slouken@3407
   131
 *  This function may be called safely at any time, even before SDL_Init().
slouken@3407
   132
 *  
slouken@3407
   133
 *  \sa SDL_VERSION
slouken@0
   134
 */
slouken@1895
   135
extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver);
slouken@0
   136
slouken@2982
   137
/**
slouken@3407
   138
 *  \brief Get the code revision of SDL that is linked against your program.
icculus@4419
   139
 *
slouken@4627
   140
 *  Returns an arbitrary string (a hash value) uniquely identifying the
slouken@4627
   141
 *  exact revision of the SDL library in use, and is only useful in comparing
slouken@4627
   142
 *  against other revisions. It is NOT an incrementing number.
slouken@2982
   143
 */
icculus@4419
   144
extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
slouken@2982
   145
slouken@5359
   146
/**
slouken@5359
   147
 *  \brief Get the revision number of SDL that is linked against your program.
slouken@5359
   148
 *
slouken@5359
   149
 *  Returns a number uniquely identifying the exact revision of the SDL
slouken@5359
   150
 *  library in use. It is an incrementing number based on commits to
slouken@5359
   151
 *  hg.libsdl.org.
slouken@5359
   152
 */
slouken@5359
   153
extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void);
slouken@5359
   154
slouken@5359
   155
slouken@0
   156
/* Ends C function definitions when using C++ */
slouken@0
   157
#ifdef __cplusplus
slouken@1895
   158
/* *INDENT-OFF* */
slouken@0
   159
}
slouken@1895
   160
/* *INDENT-ON* */
slouken@0
   161
#endif
slouken@0
   162
#include "close_code.h"
slouken@0
   163
slouken@0
   164
#endif /* _SDL_version_h */
slouken@1895
   165
slouken@1895
   166
/* vi: set ts=4 sw=4 expandtab: */