SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Macros | Functions
Querying SDL Version

Functionality to query the current SDL version, both as headers the app was compiled against, and a library the app is linked to. More...

Macros

#define SDL_MAJOR_VERSION
 The current major version of SDL headers.
 
#define SDL_MINOR_VERSION
 The current minor version of the SDL headers.
 
#define SDL_MICRO_VERSION
 The current micro (or patchlevel) version of the SDL headers.
 
#define SDL_VERSIONNUM(major, minor, patch)    ((major) * 1000000 + (minor) * 1000 + (patch))
 This macro turns the version numbers into a numeric value.
 
#define SDL_VERSIONNUM_MAJOR(version)   ((version) / 1000000)
 This macro extracts the major version from a version number.
 
#define SDL_VERSIONNUM_MINOR(version)   (((version) / 1000) % 1000)
 This macro extracts the minor version from a version number.
 
#define SDL_VERSIONNUM_MICRO(version)   ((version) % 1000)
 This macro extracts the micro version from a version number.
 
#define SDL_VERSION    SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION)
 This is the version number macro for the current SDL version.
 
#define SDL_VERSION_ATLEAST(X, Y, Z)   (SDL_VERSION >= SDL_VERSIONNUM(X, Y, Z))
 This macro will evaluate to true if compiled with SDL at least X.Y.Z.
 

Functions

int SDL::GetVersion ()
 Get the version of SDL that is linked against your program.
 
const char * SDL::GetRevision ()
 Get the code revision of SDL that is linked against your program.
 

Detailed Description

Macro Definition Documentation

◆ SDL_MAJOR_VERSION

#define SDL_MAJOR_VERSION

If this were SDL version 3.2.1, this value would be 3.

Since
This macro is available since SDL 3.2.0.

◆ SDL_MICRO_VERSION

#define SDL_MICRO_VERSION

If this were SDL version 3.2.1, this value would be 1.

Since
This macro is available since SDL 3.2.0.

◆ SDL_MINOR_VERSION

#define SDL_MINOR_VERSION

If this were SDL version 3.2.1, this value would be 2.

Since
This macro is available since SDL 3.2.0.

◆ SDL_VERSION

Since
This macro is available since SDL 3.2.0.
See also
GetVersion

◆ SDL_VERSION_ATLEAST

#define SDL_VERSION_ATLEAST (   X,
  Y,
 
)    (SDL_VERSION >= SDL_VERSIONNUM(X, Y, Z))
Since
This macro is available since SDL 3.2.0.

◆ SDL_VERSIONNUM

#define SDL_VERSIONNUM (   major,
  minor,
  patch 
)     ((major) * 1000000 + (minor) * 1000 + (patch))

(1,2,3) becomes 1002003.

Parameters
majorthe major version number.
minorthe minorversion number.
patchthe patch version number.
Since
This macro is available since SDL 3.2.0.

◆ SDL_VERSIONNUM_MAJOR

#define SDL_VERSIONNUM_MAJOR (   version)    ((version) / 1000000)

1002003 becomes 1.

Parameters
versionthe version number.
Since
This macro is available since SDL 3.2.0.

◆ SDL_VERSIONNUM_MICRO

#define SDL_VERSIONNUM_MICRO (   version)    ((version) % 1000)

1002003 becomes 3.

Parameters
versionthe version number.
Since
This macro is available since SDL 3.2.0.

◆ SDL_VERSIONNUM_MINOR

#define SDL_VERSIONNUM_MINOR (   version)    (((version) / 1000) % 1000)

1002003 becomes 2.

Parameters
versionthe version number.
Since
This macro is available since SDL 3.2.0.

Function Documentation

◆ GetRevision()

const char * SDL::GetRevision ( )
inline

This value is the revision of the code you are linked with and may be different from the code you are compiling with, which is found in the constant SDL_REVISION.

The revision is arbitrary string (a hash value) uniquely identifying the exact revision of the SDL library in use, and is only useful in comparing against other revisions. It is NOT an incrementing number.

If SDL wasn't built from a git repository with the appropriate tools, this will return an empty string.

You shouldn't use this function for anything but logging it for debugging purposes. The string is not intended to be reliable in any way.

Returns
an arbitrary string, uniquely identifying the exact revision of the SDL library in use.
Since
This function is available since SDL 3.2.0.
See also
GetVersion

◆ GetVersion()

int SDL::GetVersion ( )
inline

If you are linking to SDL dynamically, then it is possible that the current version will be different than the version you compiled against. This function returns the current version, while SDL_VERSION is the version you compiled with.

This function may be called safely at any time, even before InitSubSystem().

Returns
the version of the linked library.
Since
This function is available since SDL 3.2.0.
See also
GetRevision