SDL 3.0
SDL_version.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/**
23 * \file SDL_version.h
24 *
25 * This header defines the current SDL version.
26 */
27
28#ifndef SDL_version_h_
29#define SDL_version_h_
30
31#include <SDL3/SDL_stdinc.h>
32#include <SDL3/SDL_error.h>
33
34#include <SDL3/SDL_begin_code.h>
35/* Set up for C function definitions, even when using C++ */
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40/**
41 * Information about the version of SDL in use.
42 *
43 * Represents the library's version as three levels: major revision
44 * (increments with massive changes, additions, and enhancements), minor
45 * revision (increments with backwards-compatible changes to the major
46 * revision), and patchlevel (increments with fixes to the minor revision).
47 *
48 * \since This struct is available since SDL 3.0.0.
49 *
50 * \sa SDL_VERSION
51 * \sa SDL_GetVersion
52 */
53typedef struct SDL_Version
54{
55 Uint8 major; /**< major version */
56 Uint8 minor; /**< minor version */
57 Uint8 patch; /**< update version */
59
60/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL */
61#define SDL_MAJOR_VERSION 3
62#define SDL_MINOR_VERSION 1
63#define SDL_PATCHLEVEL 2
64
65/**
66 * Macro to determine SDL version program was compiled against.
67 *
68 * This macro fills in an SDL_Version structure with the version of the
69 * library you compiled against. This is determined by what header the
70 * compiler uses. Note that if you dynamically linked the library, you might
71 * have a slightly newer or older version at runtime. That version can be
72 * determined with SDL_GetVersion(), which, unlike SDL_VERSION(), is not a
73 * macro.
74 *
75 * \param x A pointer to an SDL_Version struct to initialize.
76 *
77 * \since This macro is available since SDL 3.0.0.
78 *
79 * \sa SDL_Version
80 * \sa SDL_GetVersion
81 */
82#define SDL_VERSION(x) \
83{ \
84 (x)->major = SDL_MAJOR_VERSION; \
85 (x)->minor = SDL_MINOR_VERSION; \
86 (x)->patch = SDL_PATCHLEVEL; \
87}
88
89/**
90 * This macro turns the version numbers into a numeric value.
91 *
92 * (1,2,3) becomes 0x1000203.
93 *
94 * \param major the major version number.
95 * \param minor the minorversion number.
96 * \param patch the patch version number.
97 *
98 * \since This macro is available since SDL 3.0.0.
99 */
100#define SDL_VERSIONNUM(major, minor, patch) \
101 ((major) << 24 | (minor) << 8 | (patch) << 0)
102
103/**
104 * This is the version number macro for the current SDL version.
105 *
106 * \since This macro is available since SDL 3.0.0.
107 */
108#define SDL_COMPILEDVERSION \
109 SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
110
111/**
112 * This macro will evaluate to true if compiled with SDL at least X.Y.Z.
113 *
114 * \since This macro is available since SDL 3.0.0.
115 */
116#define SDL_VERSION_ATLEAST(X, Y, Z) \
117 (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
118
119/**
120 * Get the version of SDL that is linked against your program.
121 *
122 * If you are linking to SDL dynamically, then it is possible that the current
123 * version will be different than the version you compiled against. This
124 * function returns the current version, while SDL_VERSION() is a macro that
125 * tells you what version you compiled with.
126 *
127 * This function may be called safely at any time, even before SDL_Init().
128 *
129 * \param ver the SDL_Version structure that contains the version information
130 * \returns 0 on success or a negative error code on failure; call
131 * SDL_GetError() for more information.
132 *
133 * \since This function is available since SDL 3.0.0.
134 *
135 * \sa SDL_GetRevision
136 */
137extern DECLSPEC int SDLCALL SDL_GetVersion(SDL_Version * ver);
138
139/**
140 * Get the code revision of SDL that is linked against your program.
141 *
142 * This value is the revision of the code you are linked with and may be
143 * different from the code you are compiling with, which is found in the
144 * constant SDL_REVISION.
145 *
146 * The revision is arbitrary string (a hash value) uniquely identifying the
147 * exact revision of the SDL library in use, and is only useful in comparing
148 * against other revisions. It is NOT an incrementing number.
149 *
150 * If SDL wasn't built from a git repository with the appropriate tools, this
151 * will return an empty string.
152 *
153 * You shouldn't use this function for anything but logging it for debugging
154 * purposes. The string is not intended to be reliable in any way.
155 *
156 * \returns an arbitrary string, uniquely identifying the exact revision of
157 * the SDL library in use.
158 *
159 * \since This function is available since SDL 3.0.0.
160 *
161 * \sa SDL_GetVersion
162 */
163extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
164
165
166/* Ends C function definitions when using C++ */
167#ifdef __cplusplus
168}
169#endif
170#include <SDL3/SDL_close_code.h>
171
172#endif /* SDL_version_h_ */
uint8_t Uint8
Definition SDL_stdinc.h:188
const char * SDL_GetRevision(void)
int SDL_GetVersion(SDL_Version *ver)