sdl3_sys/generated/
version.rs

1//! Functionality to query the current SDL version, both as headers the app was
2//! compiled against, and a library the app is linked to.
3
4use super::stdinc::*;
5
6/// The current major version of SDL headers.
7///
8/// If this were SDL version 3.2.1, this value would be 3.
9///
10/// ## Availability
11/// This macro is available since SDL 3.2.0.
12pub const SDL_MAJOR_VERSION: ::core::primitive::i32 = 3;
13
14/// The current minor version of the SDL headers.
15///
16/// If this were SDL version 3.2.1, this value would be 2.
17///
18/// ## Availability
19/// This macro is available since SDL 3.2.0.
20pub const SDL_MINOR_VERSION: ::core::primitive::i32 = 4;
21
22/// The current micro (or patchlevel) version of the SDL headers.
23///
24/// If this were SDL version 3.2.1, this value would be 1.
25///
26/// ## Availability
27/// This macro is available since SDL 3.2.0.
28pub const SDL_MICRO_VERSION: ::core::primitive::i32 = 0;
29
30/// This macro turns the version numbers into a numeric value.
31///
32/// (1,2,3) becomes 1002003.
33///
34/// ## Parameters
35/// - `major`: the major version number.
36/// - `minor`: the minorversion number.
37/// - `patch`: the patch version number.
38///
39/// ## Availability
40/// This macro is available since SDL 3.2.0.
41#[inline(always)]
42pub const fn SDL_VERSIONNUM(
43    major: ::core::primitive::i32,
44    minor: ::core::primitive::i32,
45    patch: ::core::primitive::i32,
46) -> ::core::primitive::i32 {
47    (((major * 1000000_i32) + (minor * 1000_i32)) + patch)
48}
49
50/// This macro extracts the major version from a version number
51///
52/// 1002003 becomes 1.
53///
54/// ## Parameters
55/// - `version`: the version number.
56///
57/// ## Availability
58/// This macro is available since SDL 3.2.0.
59#[inline(always)]
60pub const fn SDL_VERSIONNUM_MAJOR(version: ::core::primitive::i32) -> ::core::primitive::i32 {
61    (version / 1000000_i32)
62}
63
64/// This macro extracts the minor version from a version number
65///
66/// 1002003 becomes 2.
67///
68/// ## Parameters
69/// - `version`: the version number.
70///
71/// ## Availability
72/// This macro is available since SDL 3.2.0.
73#[inline(always)]
74pub const fn SDL_VERSIONNUM_MINOR(version: ::core::primitive::i32) -> ::core::primitive::i32 {
75    ((version / 1000_i32) % 1000_i32)
76}
77
78/// This macro extracts the micro version from a version number
79///
80/// 1002003 becomes 3.
81///
82/// ## Parameters
83/// - `version`: the version number.
84///
85/// ## Availability
86/// This macro is available since SDL 3.2.0.
87#[inline(always)]
88pub const fn SDL_VERSIONNUM_MICRO(version: ::core::primitive::i32) -> ::core::primitive::i32 {
89    (version % 1000_i32)
90}
91
92/// This is the version number macro for the current SDL version.
93///
94/// ## Availability
95/// This macro is available since SDL 3.2.0.
96///
97/// ## See also
98/// - [`SDL_GetVersion`]
99pub const SDL_VERSION: ::core::primitive::i32 =
100    SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
101
102/// This macro will evaluate to true if compiled with SDL at least X.Y.Z.
103///
104/// ## Availability
105/// This macro is available since SDL 3.2.0.
106#[inline(always)]
107pub const fn SDL_VERSION_ATLEAST(
108    X: ::core::primitive::i32,
109    Y: ::core::primitive::i32,
110    Z: ::core::primitive::i32,
111) -> ::core::primitive::bool {
112    (SDL_VERSION >= SDL_VERSIONNUM(X, Y, Z))
113}
114
115unsafe extern "C" {
116    /// Get the version of SDL that is linked against your program.
117    ///
118    /// If you are linking to SDL dynamically, then it is possible that the current
119    /// version will be different than the version you compiled against. This
120    /// function returns the current version, while [`SDL_VERSION`] is the version you
121    /// compiled with.
122    ///
123    /// This function may be called safely at any time, even before [`SDL_Init()`].
124    ///
125    /// ## Return value
126    /// Returns the version of the linked library.
127    ///
128    /// ## Availability
129    /// This function is available since SDL 3.2.0.
130    ///
131    /// ## See also
132    /// - [`SDL_GetRevision`]
133    pub safe fn SDL_GetVersion() -> ::core::ffi::c_int;
134}
135
136unsafe extern "C" {
137    /// Get the code revision of the SDL library that is linked against your
138    /// program.
139    ///
140    /// This value is the revision of the code you are linking against and may be
141    /// different from the code you are compiling with, which is found in the
142    /// constant [`SDL_REVISION`] if you explicitly include SDL_revision.h
143    ///
144    /// The revision is an arbitrary string (a hash value) uniquely identifying the
145    /// exact revision of the SDL library in use, and is only useful in comparing
146    /// against other revisions. It is NOT an incrementing number.
147    ///
148    /// If SDL wasn't built from a git repository with the appropriate tools, this
149    /// will return an empty string.
150    ///
151    /// You shouldn't use this function for anything but logging it for debugging
152    /// purposes. The string is not intended to be reliable in any way.
153    ///
154    /// ## Return value
155    /// Returns an arbitrary string, uniquely identifying the exact revision of
156    ///   the SDL library in use.
157    ///
158    /// ## Availability
159    /// This function is available since SDL 3.2.0.
160    ///
161    /// ## See also
162    /// - [`SDL_GetVersion`]
163    pub safe fn SDL_GetRevision() -> *const ::core::ffi::c_char;
164}
165
166#[cfg(doc)]
167use crate::everything::*;