mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-19 22:10:52 +00:00
Removed the SDL_Version structure, moved SDL version to SDL.h
Inspired by https://github.com/libsdl-org/SDL/issues/9788
This commit is contained in:
@@ -28,6 +28,14 @@
|
||||
#ifndef SDL_h_
|
||||
#define SDL_h_
|
||||
|
||||
/**
|
||||
* The current version of SDL
|
||||
*/
|
||||
#define SDL_MAJOR_VERSION 3
|
||||
#define SDL_MINOR_VERSION 1
|
||||
#define SDL_MICRO_VERSION 2
|
||||
|
||||
|
||||
#include <SDL3/SDL_stdinc.h>
|
||||
#include <SDL3/SDL_assert.h>
|
||||
#include <SDL3/SDL_atomic.h>
|
||||
|
||||
@@ -529,7 +529,8 @@
|
||||
#define SDL_GetTicks64 SDL_GetTicks
|
||||
|
||||
/* ##SDL_version.h */
|
||||
#define SDL_version SDL_Version
|
||||
#define SDL_COMPILEDVERSION SDL_VERSION
|
||||
#define SDL_PATCHLEVEL SDL_MICRO_VERSION
|
||||
|
||||
/* ##SDL_video.h */
|
||||
#define SDL_GetClosestDisplayMode SDL_GetClosestFullscreenDisplayMode
|
||||
@@ -1038,7 +1039,8 @@
|
||||
#define SDL_GetTicks64 SDL_GetTicks64_renamed_SDL_GetTicks
|
||||
|
||||
/* ##SDL_version.h */
|
||||
#define SDL_version SDL_version_renamed_SDL_Version
|
||||
#define SDL_COMPILEDVERSION SDL_COMPILEDVERSION_renamed_SDL_VERSION
|
||||
#define SDL_PATCHLEVEL SDL_PATCHLEVEL_renamed_SDL_MICRO_VERSION
|
||||
|
||||
/* ##SDL_video.h */
|
||||
#define SDL_GetClosestDisplayMode SDL_GetClosestDisplayMode_renamed_SDL_GetClosestFullscreenDisplayMode
|
||||
|
||||
@@ -37,59 +37,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 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), and patchlevel (increments with fixes to the minor revision).
|
||||
*
|
||||
* \since This struct is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_VERSION
|
||||
* \sa SDL_GetVersion
|
||||
*/
|
||||
typedef struct SDL_Version
|
||||
{
|
||||
Uint8 major; /**< major version */
|
||||
Uint8 minor; /**< minor version */
|
||||
Uint8 patch; /**< update version */
|
||||
} SDL_Version;
|
||||
|
||||
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL */
|
||||
#define SDL_MAJOR_VERSION 3
|
||||
#define SDL_MINOR_VERSION 1
|
||||
#define SDL_PATCHLEVEL 2
|
||||
|
||||
/**
|
||||
* Macro to determine SDL version program was compiled against.
|
||||
*
|
||||
* This macro fills in an SDL_Version structure with the version of the
|
||||
* library you compiled against. This is determined by what header the
|
||||
* compiler uses. Note that if you dynamically linked the library, you might
|
||||
* have a slightly newer or older version at runtime. That version can be
|
||||
* determined with SDL_GetVersion(), which, unlike SDL_VERSION(), is not a
|
||||
* macro.
|
||||
*
|
||||
* \param x A pointer to an SDL_Version struct to initialize.
|
||||
*
|
||||
* \since This macro is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_Version
|
||||
* \sa SDL_GetVersion
|
||||
*/
|
||||
#define SDL_VERSION(x) \
|
||||
{ \
|
||||
(x)->major = SDL_MAJOR_VERSION; \
|
||||
(x)->minor = SDL_MINOR_VERSION; \
|
||||
(x)->patch = SDL_PATCHLEVEL; \
|
||||
}
|
||||
|
||||
/**
|
||||
* This macro turns the version numbers into a numeric value.
|
||||
*
|
||||
* (1,2,3) becomes 0x1000203.
|
||||
* (1,2,3) becomes 1002003.
|
||||
*
|
||||
* \param major the major version number.
|
||||
* \param minor the minorversion number.
|
||||
@@ -98,15 +49,48 @@ typedef struct SDL_Version
|
||||
* \since This macro is available since SDL 3.0.0.
|
||||
*/
|
||||
#define SDL_VERSIONNUM(major, minor, patch) \
|
||||
((major) << 24 | (minor) << 8 | (patch) << 0)
|
||||
((major) * 1000000 + (minor) * 1000 + (patch))
|
||||
|
||||
/**
|
||||
* This macro extracts the major version from a version number
|
||||
*
|
||||
* 1002003 becomes 1.
|
||||
*
|
||||
* \param version the version number.
|
||||
*
|
||||
* \since This macro is available since SDL 3.0.0.
|
||||
*/
|
||||
#define SDL_VERSIONNUM_MAJOR(version) ((version) / 1000000)
|
||||
|
||||
/**
|
||||
* This macro extracts the minor version from a version number
|
||||
*
|
||||
* 1002003 becomes 2.
|
||||
*
|
||||
* \param version the version number.
|
||||
*
|
||||
* \since This macro is available since SDL 3.0.0.
|
||||
*/
|
||||
#define SDL_VERSIONNUM_MINOR(version) (((version) / 1000) % 1000)
|
||||
|
||||
/**
|
||||
* This macro extracts the micro version from a version number
|
||||
*
|
||||
* 1002003 becomes 3.
|
||||
*
|
||||
* \param version the version number.
|
||||
*
|
||||
* \since This macro is available since SDL 3.0.0.
|
||||
*/
|
||||
#define SDL_VERSIONNUM_MICRO(version) ((version) % 1000)
|
||||
|
||||
/**
|
||||
* This is the version number macro for the current SDL version.
|
||||
*
|
||||
* \since This macro is available since SDL 3.0.0.
|
||||
*/
|
||||
#define SDL_COMPILEDVERSION \
|
||||
SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
|
||||
#define SDL_VERSION \
|
||||
SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION)
|
||||
|
||||
/**
|
||||
* This macro will evaluate to true if compiled with SDL at least X.Y.Z.
|
||||
@@ -114,27 +98,25 @@ typedef struct SDL_Version
|
||||
* \since This macro is available since SDL 3.0.0.
|
||||
*/
|
||||
#define SDL_VERSION_ATLEAST(X, Y, Z) \
|
||||
(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
|
||||
(SDL_VERSION >= SDL_VERSIONNUM(X, Y, Z))
|
||||
|
||||
/**
|
||||
* Get the version of SDL that is linked against your program.
|
||||
*
|
||||
* 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 a macro that
|
||||
* tells you what version you compiled with.
|
||||
* 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 SDL_Init().
|
||||
*
|
||||
* \param ver the SDL_Version structure that contains the version information
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
* \returns the version of the linked library.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetRevision
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetVersion(SDL_Version * ver);
|
||||
extern DECLSPEC int SDLCALL SDL_GetVersion(void);
|
||||
|
||||
/**
|
||||
* Get the code revision of SDL that is linked against your program.
|
||||
|
||||
Reference in New Issue
Block a user