SDL 3.0
SDL_version.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2026 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 * # CategoryVersion
24 *
25 * Functionality to query the current SDL version, both as headers the app was
26 * compiled against, and a library the app is linked to.
27 */
28
29#ifndef SDL_version_h_
30#define SDL_version_h_
31
32#include <SDL3/SDL_stdinc.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 * The current major version of SDL headers.
42 *
43 * If this were SDL version 3.2.1, this value would be 3.
44 *
45 * \since This macro is available since SDL 3.2.0.
46 */
47#define SDL_MAJOR_VERSION 3
48
49/**
50 * The current minor version of the SDL headers.
51 *
52 * If this were SDL version 3.2.1, this value would be 2.
53 *
54 * \since This macro is available since SDL 3.2.0.
55 */
56#define SDL_MINOR_VERSION 4
57
58/**
59 * The current micro (or patchlevel) version of the SDL headers.
60 *
61 * If this were SDL version 3.2.1, this value would be 1.
62 *
63 * \since This macro is available since SDL 3.2.0.
64 */
65#define SDL_MICRO_VERSION 2
66
67/**
68 * This macro turns the version numbers into a numeric value.
69 *
70 * (1,2,3) becomes 1002003.
71 *
72 * \param major the major version number.
73 * \param minor the minorversion number.
74 * \param patch the patch version number.
75 *
76 * \since This macro is available since SDL 3.2.0.
77 */
78#define SDL_VERSIONNUM(major, minor, patch) \
79 ((major) * 1000000 + (minor) * 1000 + (patch))
80
81/**
82 * This macro extracts the major version from a version number
83 *
84 * 1002003 becomes 1.
85 *
86 * \param version the version number.
87 *
88 * \threadsafety It is safe to call this macro from any thread.
89 *
90 * \since This macro is available since SDL 3.2.0.
91 */
92#define SDL_VERSIONNUM_MAJOR(version) ((version) / 1000000)
93
94/**
95 * This macro extracts the minor version from a version number
96 *
97 * 1002003 becomes 2.
98 *
99 * \param version the version number.
100 *
101 * \threadsafety It is safe to call this macro from any thread.
102 *
103 * \since This macro is available since SDL 3.2.0.
104 */
105#define SDL_VERSIONNUM_MINOR(version) (((version) / 1000) % 1000)
106
107/**
108 * This macro extracts the micro version from a version number
109 *
110 * 1002003 becomes 3.
111 *
112 * \param version the version number.
113 *
114 * \threadsafety It is safe to call this macro from any thread.
115 *
116 * \since This macro is available since SDL 3.2.0.
117 */
118#define SDL_VERSIONNUM_MICRO(version) ((version) % 1000)
119
120/**
121 * This is the version number macro for the current SDL version.
122 *
123 * \threadsafety It is safe to call this macro from any thread.
124 *
125 * \since This macro is available since SDL 3.2.0.
126 *
127 * \sa SDL_GetVersion
128 */
129#define SDL_VERSION \
130 SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION)
131
132/**
133 * This macro will evaluate to true if compiled with SDL at least X.Y.Z.
134 *
135 * \threadsafety It is safe to call this macro from any thread.
136 *
137 * \since This macro is available since SDL 3.2.0.
138 */
139#define SDL_VERSION_ATLEAST(X, Y, Z) \
140 (SDL_VERSION >= SDL_VERSIONNUM(X, Y, Z))
141
142/**
143 * Get the version of SDL that is linked against your program.
144 *
145 * If you are linking to SDL dynamically, then it is possible that the current
146 * version will be different than the version you compiled against. This
147 * function returns the current version, while SDL_VERSION is the version you
148 * compiled with.
149 *
150 * This function may be called safely at any time, even before SDL_Init().
151 *
152 * \returns the version of the linked library.
153 *
154 * \threadsafety It is safe to call this function from any thread.
155 *
156 * \since This function is available since SDL 3.2.0.
157 *
158 * \sa SDL_GetRevision
159 */
160extern SDL_DECLSPEC int SDLCALL SDL_GetVersion(void);
161
162/**
163 * Get the code revision of the SDL library that is linked against your
164 * program.
165 *
166 * This value is the revision of the code you are linking against and may be
167 * different from the code you are compiling with, which is found in the
168 * constant SDL_REVISION if you explicitly include SDL_revision.h
169 *
170 * The revision is an arbitrary string (a hash value) uniquely identifying the
171 * exact revision of the SDL library in use, and is only useful in comparing
172 * against other revisions. It is NOT an incrementing number.
173 *
174 * If SDL wasn't built from a git repository with the appropriate tools, this
175 * will return an empty string.
176 *
177 * You shouldn't use this function for anything but logging it for debugging
178 * purposes. The string is not intended to be reliable in any way.
179 *
180 * \returns an arbitrary string, uniquely identifying the exact revision of
181 * the SDL library in use.
182 *
183 * \threadsafety It is safe to call this function from any thread.
184 *
185 * \since This function is available since SDL 3.2.0.
186 *
187 * \sa SDL_GetVersion
188 */
189extern SDL_DECLSPEC const char * SDLCALL SDL_GetRevision(void);
190
191
192/* Ends C function definitions when using C++ */
193#ifdef __cplusplus
194}
195#endif
196#include <SDL3/SDL_close_code.h>
197
198#endif /* SDL_version_h_ */
int SDL_GetVersion(void)
const char * SDL_GetRevision(void)