TR_datastructures 0.1.0
A generic C data structures library
Loading...
Searching...
No Matches
Macros
tr_version.h File Reference

Version information for the tr_datastructures library. More...

Go to the source code of this file.

Macros

#define TR_VERSION_MAJOR   0
 
#define TR_VERSION_MINOR   1
 
#define TR_VERSION_PATCH   0
 
#define TR_VERSION_STRING   "0.1.0"
 
#define TR_VERSION_ENCODE(major, minor, patch)    (((major) << 16) | ((minor) << 8) | (patch))
 Encodes major, minor and patch into a single integer.
 
#define TR_VERSION    TR_VERSION_ENCODE(TR_VERSION_MAJOR, TR_VERSION_MINOR, TR_VERSION_PATCH)
 Current library version encoded as a single integer.
 
#define TR_VERSION_AT_LEAST(major, minor, patch)    (TR_VERSION >= TR_VERSION_ENCODE(major, minor, patch))
 Checks if the current version is at least major.minor.patch.
 

Detailed Description

Version information for the tr_datastructures library.

This file is automatically generated by CMake from cmake/tr_version.h.in — do not edit manually. The version numbers are taken directly from the VERSION field in the root CMakeLists.txt.

Example usage:

#if TR_VERSION_AT_LEAST(1, 0, 0)
// use features from 1.0.0 onwards
#endif
printf("TR_datastructures version: %s\n", TR_VERSION_STRING);
#define TR_VERSION_STRING
Definition tr_version.h:85
Version information for the tr_datastructures library.

Macro Definition Documentation

◆ TR_VERSION

Current library version encoded as a single integer.

Combines TR_VERSION_MAJOR, TR_VERSION_MINOR and TR_VERSION_PATCH into a single integer using TR_VERSION_ENCODE. Use with TR_VERSION_AT_LEAST for version checks.

Example:

printf("Version code: 0x%06X\n", TR_VERSION);
#define TR_VERSION
Current library version encoded as a single integer.
Definition tr_version.h:132

◆ TR_VERSION_AT_LEAST

#define TR_VERSION_AT_LEAST (   major,
  minor,
  patch 
)     (TR_VERSION >= TR_VERSION_ENCODE(major, minor, patch))

Checks if the current version is at least major.minor.patch.

The recommended way to perform compile time version checks. Evaluates to 1 if the current library version is greater than or equal to the specified version, 0 otherwise.

Example:

#if TR_VERSION_AT_LEAST(1, 0, 0)
// safe to use features added in 1.0.0
#endif
Parameters
majorRequired major version
minorRequired minor version
patchRequired patch version

◆ TR_VERSION_ENCODE

#define TR_VERSION_ENCODE (   major,
  minor,
  patch 
)     (((major) << 16) | ((minor) << 8) | (patch))

Encodes major, minor and patch into a single integer.

Packs three version components into a single 32 bit integer for easy numerical comparison. The encoding is:

(major << 16) | (minor << 8) | patch

Example — version 1.2.3 encodes to 0x00010203:

#if TR_VERSION >= TR_VERSION_ENCODE(1, 2, 0)
// version is at least 1.2.0
#endif
Parameters
majorMajor version component
minorMinor version component
patchPatch version component