nm-version: allow to define NM_VERSION_MAX_ALLOWED alone

Previously, if NM_VERSION_MIN_REQUIRED was not defined, it defaulted to
NM_VERSION. As a consequence, if NM_VERSION_MAX_ALLOWED was defined we
got a compilation error because MAX_ALLOWED < MIN_REQUIRED.

MAX_ALLOWED is used to get compilation warnings if you unintentionally
use a libnm's symbol introduced in a newer version. MIN_REQUIRED is used
to get rid of warnings about symbol deprecations.

Libnm users may want to use MAX_ALLOWED alone, because using a too new
symbol would fail to compile with older libnm. But they might want to
get deprecation warnings as soon as possible, so they want to leave
MIN_REQUIRED empty.
This commit is contained in:
Íñigo Huguet 2025-12-23 16:09:39 +01:00
parent 36275bc51c
commit f849163e82

View file

@ -12,16 +12,16 @@
/* Deprecation / Availability macros */
#if !defined(NM_VERSION_MIN_REQUIRED) || (NM_VERSION_MIN_REQUIRED == 0)
#undef NM_VERSION_MIN_REQUIRED
#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_API_VERSION)
#endif
#if !defined(NM_VERSION_MIN_REQUIRED) || (NM_VERSION_MIN_REQUIRED == 0)
#undef NM_VERSION_MIN_REQUIRED
#define NM_VERSION_MIN_REQUIRED (NM_VERSION_MAX_ALLOWED)
#endif
/* sanity checks */
#if NM_VERSION_MIN_REQUIRED > NM_API_VERSION
#error "NM_VERSION_MIN_REQUIRED must be <= NM_API_VERSION"