version: rename macro NM_VERSION_CUR_STABLE to NM_API_VERSION

NM_API_VERSION is a better name. It's not the current stable
version, but the version number of the API which the current
NM_VERSION provides. In practice, NM_API_VERSION is either identical
to NM_VERSION (in case of a release) or NM_VERSION is a development
version leading up the the upcoming NM_API_VERSION.

For example, with the new name the check

  #if NM_VERSION != NM_API_VERSION
  # warning this is an development version
  #endif

makes more sense.
This commit is contained in:
Thomas Haller 2018-01-16 16:01:49 +01:00
parent 165fe65eef
commit 4da1480cfd
3 changed files with 21 additions and 11 deletions

View file

@ -29,17 +29,17 @@
#if !defined (NM_VERSION_MIN_REQUIRED) || (NM_VERSION_MIN_REQUIRED == 0)
# undef NM_VERSION_MIN_REQUIRED
# define NM_VERSION_MIN_REQUIRED (NM_VERSION_CUR_STABLE)
# define NM_VERSION_MIN_REQUIRED (NM_API_VERSION)
#endif
#if !defined (NM_VERSION_MAX_ALLOWED) || (NM_VERSION_MAX_ALLOWED == 0)
# undef NM_VERSION_MAX_ALLOWED
# define NM_VERSION_MAX_ALLOWED (NM_VERSION_CUR_STABLE)
# define NM_VERSION_MAX_ALLOWED (NM_API_VERSION)
#endif
/* sanity checks */
#if NM_VERSION_MIN_REQUIRED > NM_VERSION_CUR_STABLE
#error "NM_VERSION_MIN_REQUIRED must be <= NM_VERSION_CUR_STABLE"
#if NM_VERSION_MIN_REQUIRED > NM_API_VERSION
#error "NM_VERSION_MIN_REQUIRED must be <= NM_API_VERSION"
#endif
#if NM_VERSION_MAX_ALLOWED < NM_VERSION_MIN_REQUIRED
#error "NM_VERSION_MAX_ALLOWED must be >= NM_VERSION_MIN_REQUIRED"

View file

@ -29,17 +29,17 @@
#if !defined (NM_VERSION_MIN_REQUIRED) || (NM_VERSION_MIN_REQUIRED == 0)
# undef NM_VERSION_MIN_REQUIRED
# define NM_VERSION_MIN_REQUIRED (NM_VERSION_CUR_STABLE)
# define NM_VERSION_MIN_REQUIRED (NM_API_VERSION)
#endif
#if !defined (NM_VERSION_MAX_ALLOWED) || (NM_VERSION_MAX_ALLOWED == 0)
# undef NM_VERSION_MAX_ALLOWED
# define NM_VERSION_MAX_ALLOWED (NM_VERSION_CUR_STABLE)
# define NM_VERSION_MAX_ALLOWED (NM_API_VERSION)
#endif
/* sanity checks */
#if NM_VERSION_MIN_REQUIRED > NM_VERSION_CUR_STABLE
#error "NM_VERSION_MIN_REQUIRED must be <= NM_VERSION_CUR_STABLE"
#if NM_VERSION_MIN_REQUIRED > NM_API_VERSION
#error "NM_VERSION_MIN_REQUIRED must be <= NM_API_VERSION"
#endif
#if NM_VERSION_MAX_ALLOWED < NM_VERSION_MIN_REQUIRED
#error "NM_VERSION_MAX_ALLOWED must be >= NM_VERSION_MIN_REQUIRED"

View file

@ -74,13 +74,23 @@
#define NM_VERSION_1_10 (NM_ENCODE_VERSION (1, 10, 0))
#define NM_VERSION_1_12 (NM_ENCODE_VERSION (1, 12, 0))
#define NM_VERSION_CUR_STABLE \
/* For releases, NM_API_VERSION is equal to NM_VERSION.
*
* For development builds, NM_API_VERSION is the next
* stable API after NM_VERSION. When you run a development
* version, you are already using the future API, even if
* it is not yet release. Hence, the currently used API
* version is the future one. */
#define NM_API_VERSION \
(((NM_MINOR_VERSION % 2) == 1) \
? NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION + 1, 0 ) \
: NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION , ((NM_MICRO_VERSION + 1) / 2) * 2))
/* deprecated define. */
#define NM_VERSION_NEXT_STABLE NM_VERSION_CUR_STABLE
/* deprecated. */
#define NM_VERSION_CUR_STABLE NM_API_VERSION
/* deprecated. */
#define NM_VERSION_NEXT_STABLE NM_API_VERSION
#define NM_VERSION NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION, NM_MICRO_VERSION)