MessagePack for C
Loading...
Searching...
No Matches
workaround.h
Go to the documentation of this file.
1/*
2Copyright Rene Rivera 2017
3Distributed under the Boost Software License, Version 1.0.
4(See accompanying file LICENSE_1_0.txt or copy at
5http://www.boost.org/LICENSE_1_0.txt)
6*/
7
8#ifndef MSGPACK_PREDEF_WORKAROUND_H
9#define MSGPACK_PREDEF_WORKAROUND_H
10
11/*`
12[heading `MSGPACK_PREDEF_WORKAROUND`]
13
14``
15MSGPACK_PREDEF_WORKAROUND(symbol,comp,major,minor,patch)
16``
17
18Usage:
19
20``
21#if MSGPACK_PREDEF_WORKAROUND(MSGPACK_COMP_CLANG,<,3,0,0)
22 // Workaround for old clang compilers..
23#endif
24``
25
26Defines a comparison against two version numbers that depends on the definion
27of `MSGPACK_STRICT_CONFIG`. When `MSGPACK_STRICT_CONFIG` is defined this will expand
28to a value convertible to `false`. Which has the effect of disabling all code
29conditionally guarded by `MSGPACK_PREDEF_WORKAROUND`. When `MSGPACK_STRICT_CONFIG`
30is undefine this expand to test the given `symbol` version value with the
31`comp` comparison against `MSGPACK_VERSION_NUMBER(major,minor,patch)`.
32*/
33#ifdef MSGPACK_STRICT_CONFIG
34# define MSGPACK_PREDEF_WORKAROUND(symbol, comp, major, minor, patch) (0)
35#else
37# define MSGPACK_PREDEF_WORKAROUND(symbol, comp, major, minor, patch) \
38 ( (symbol) != (0) ) && \
39 ( (symbol) comp (MSGPACK_VERSION_NUMBER( (major) , (minor) , (patch) )) )
40#endif
41
42/*`
43[heading `MSGPACK_PREDEF_TESTED_AT`]
44
45``
46MSGPACK_PREDEF_TESTED_AT(symbol,major,minor,patch)
47``
48
49Usage:
50
51``
52#if MSGPACK_PREDEF_TESTED_AT(MSGPACK_COMP_CLANG,3,5,0)
53 // Needed for clang, and last checked for 3.5.0.
54#endif
55``
56
57Defines a comparison against two version numbers that depends on the definion
58of `MSGPACK_STRICT_CONFIG` and `MSGPACK_DETECT_OUTDATED_WORKAROUNDS`.
59When `MSGPACK_STRICT_CONFIG` is defined this will expand to a value convertible
60to `false`. Which has the effect of disabling all code
61conditionally guarded by `MSGPACK_PREDEF_TESTED_AT`. When `MSGPACK_STRICT_CONFIG`
62is undefined this expand to either:
63
64* A value convertible to `true` when `MSGPACK_DETECT_OUTDATED_WORKAROUNDS` is not
65 defined.
66* A value convertible `true` when the expansion of
67 `MSGPACK_PREDEF_WORKAROUND(symbol, <=, major, minor, patch)` is `true` and
68 `MSGPACK_DETECT_OUTDATED_WORKAROUNDS` is defined.
69* A compile error when the expansion of
70 `MSGPACK_PREDEF_WORKAROUND(symbol, >, major, minor, patch)` is true and
71 `MSGPACK_DETECT_OUTDATED_WORKAROUNDS` is defined.
72*/
73#ifdef MSGPACK_STRICT_CONFIG
74# define MSGPACK_PREDEF_TESTED_AT(symbol, major, minor, patch) (0)
75#else
76# ifdef MSGPACK_DETECT_OUTDATED_WORKAROUNDS
77# define MSGPACK_PREDEF_TESTED_AT(symbol, major, minor, patch) ( \
78 MSGPACK_PREDEF_WORKAROUND(symbol, <=, major, minor, patch) \
79 ? 1 \
80 : (1%0) )
81# else
82# define MSGPACK_PREDEF_TESTED_AT(symbol, major, minor, patch) \
83 ( (symbol) >= MSGPACK_VERSION_NUMBER_AVAILABLE )
84# endif
85#endif
86
87#endif