summaryrefslogtreecommitdiff
path: root/toxcore/tox.h
diff options
context:
space:
mode:
authorsudden6 <sudden6@gmx.at>2016-12-11 17:45:03 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-12-13 02:06:25 +0000
commit3cfe5544b1cb01771b5a1f722311502127265d0b (patch)
tree4c6887dd506dbfd20df8709a6a2e0046c123cc10 /toxcore/tox.h
parent2dc2ac52b93e3a922337294c1e32f7bed794788f (diff)
Fix version compatibility test.
Also added some test cases for it.
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r--toxcore/tox.h25
1 files changed, 18 insertions, 7 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h
index 4998609d..6d23aaf8 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -186,13 +186,24 @@ uint32_t tox_version_patch(void);
186 186
187/** 187/**
188 * A macro to check at preprocessing time whether the client code is compatible 188 * A macro to check at preprocessing time whether the client code is compatible
189 * with the installed version of Tox. 189 * with the installed version of Tox. Leading zeros in the version number are
190 */ 190 * ignored. E.g. 0.1.5 is to 0.1.4 what 1.5 is to 1.4, that is: it can add new
191#define TOX_VERSION_IS_API_COMPATIBLE(MAJOR, MINOR, PATCH) \ 191 * features, but can't break the API.
192 (TOX_VERSION_MAJOR == MAJOR && \ 192 */
193 (TOX_VERSION_MINOR > MINOR || \ 193#define TOX_VERSION_IS_API_COMPATIBLE(MAJOR, MINOR, PATCH) \
194 (TOX_VERSION_MINOR == MINOR && \ 194 (TOX_VERSION_MAJOR > 0 && TOX_VERSION_MAJOR == MAJOR) && ( \
195 TOX_VERSION_PATCH >= PATCH))) 195 /* 1.x.x, 2.x.x, etc. with matching major version. */ \
196 TOX_VERSION_MINOR > MINOR || \
197 TOX_VERSION_MINOR == MINOR && TOX_VERSION_PATCH >= PATCH \
198 ) || (TOX_VERSION_MAJOR == 0 && MAJOR == 0) && ( \
199 /* 0.x.x makes minor behave like major above. */ \
200 (TOX_VERSION_MINOR > 0 && TOX_VERSION_MINOR == MINOR) && ( \
201 TOX_VERSION_PATCH >= PATCH \
202 ) || (TOX_VERSION_MINOR == 0 && MINOR == 0) && ( \
203 /* 0.0.x and 0.0.y are only compatible if x == y. */ \
204 TOX_VERSION_PATCH == PATCH \
205 ) \
206 )
196 207
197/** 208/**
198 * A macro to make compilation fail if the client code is not compatible with 209 * A macro to make compilation fail if the client code is not compatible with