1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Lets you get info about the runtime SDL version.

use crate::{c_char, stdinc::*};

#[allow(unused)]
use crate::*;

/// Information about the version of SDL in use.
///
/// Represents the library's version as three levels:
/// * major revision (increments with massive changes, additions, and
///   enhancements)
/// * minor revision (increments with backwards-compatible changes to the major
///   revision)
/// * patchlevel (increments with fixes to the minor revision).
///
/// See Also: [`SDL_VERSION`], [`SDL_GetVersion`]
///
/// **To Be Clear: The SDL library doesn't subscribe to SemVer.**
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_version {
  /// major version
  pub major: Uint8,
  /// minor version
  pub minor: Uint8,
  /// update version
  pub patch: Uint8,
}

/// SDL Major version that this lib was compiled against.
pub const SDL_MAJOR_VERSION: u8 = 2;
/// SDL Minor version that this lib was compiled against.
pub const SDL_MINOR_VERSION: u8 = 0;
/// SDL Patch version that this lib was compiled against.
pub const SDL_PATCHLEVEL: u8 = 16;

/// Writes the version of SDL that this lib was compiled against into the
/// struct.
pub fn SDL_VERSION(x: &mut SDL_version) {
  x.major = SDL_MAJOR_VERSION;
  x.minor = SDL_MINOR_VERSION;
  x.patch = SDL_PATCHLEVEL;
}

extern "C" {
  /// Get the version of SDL that is being used at runtime.
  ///
  /// It is possible that the runtime SDL version will be higher than the
  /// version you compiled against. In this case, the version will still be ABI
  /// compatible with the version you targeted at compile time.
  ///
  /// This function may be called safely at any time, even before [`SDL_Init`].
  pub fn SDL_GetVersion(ver: *mut SDL_version);

  /// Get the "code revision" of SDL that is being used at runtime.
  ///
  /// Returns an arbitrary string (a hash value) uniquely identifying the exact
  /// code revision of the SDL library in use. This is only useful in comparing
  /// against other revisions. It is NOT an incrementing number.
  ///
  /// This is a static string, do not free it.
  pub fn SDL_GetRevision() -> *const c_char;
}