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