|
37 | 37 | // within the same executable/library, the symbols have to be unique per version. |
38 | 38 | // We achieve this by using a versioned namespace that we optionally inline. |
39 | 39 | // To disable namespace inlining, define SJSON_CPP_NO_INLINE_NAMESPACE before including |
40 | | -// any sjson-cpp header. |
| 40 | +// any sjson-cpp header. To disable the versioned namespace altogether, |
| 41 | +// define SJSON_CPP_NO_VERSION_NAMESPACE before including any sjson-cpp header. |
41 | 42 | //////////////////////////////////////////////////////////////////////////////// |
42 | 43 |
|
| 44 | +#if !defined(SJSON_CPP_NO_VERSION_NAMESPACE) |
| 45 | + #if defined(_MSC_VER) && !defined(__clang__) && _MSC_VER == 1900 |
| 46 | + // VS2015 struggles with type resolution when inline namespaces are used |
| 47 | + // For that reason, we disable it explicitly |
| 48 | + #define SJSON_CPP_NO_VERSION_NAMESPACE |
| 49 | + #endif |
| 50 | +#endif |
| 51 | + |
43 | 52 | // Name of the namespace, e.g. v08 |
44 | 53 | #define SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME v ## SJSON_CPP_VERSION_MAJOR ## SJSON_CPP_VERSION_MINOR |
45 | 54 |
|
46 | | -#if defined(SJSON_CPP_NO_INLINE_NAMESPACE) |
47 | | - // Namespace won't be inlined, its usage will have to be qualified with the |
48 | | - // full version everywhere |
49 | | - #define SJSON_CPP_IMPL_NAMESPACE sjson::SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME |
| 55 | +#if defined(SJSON_CPP_NO_VERSION_NAMESPACE) |
| 56 | + // Namespace is inlined, its usage does not need to be qualified with the |
| 57 | + // full version everywhere |
| 58 | + #define SJSON_CPP_IMPL_NAMESPACE sjson |
| 59 | + |
| 60 | + #define SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN |
| 61 | + #define SJSON_CPP_IMPL_VERSION_NAMESPACE_END |
| 62 | +#elif defined(SJSON_CPP_NO_INLINE_NAMESPACE) |
| 63 | + // Namespace won't be inlined, its usage will have to be qualified with the |
| 64 | + // full version everywhere |
| 65 | + #define SJSON_CPP_IMPL_NAMESPACE sjson::SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME |
50 | 66 |
|
51 | | - #define SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN \ |
52 | | - namespace SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME \ |
53 | | - { |
| 67 | + #define SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN \ |
| 68 | + namespace SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME \ |
| 69 | + { |
| 70 | + |
| 71 | + #define SJSON_CPP_IMPL_VERSION_NAMESPACE_END \ |
| 72 | + } |
54 | 73 | #else |
55 | | - // Namespace is inlined, its usage does not need to be qualified with the |
56 | | - // full version everywhere |
57 | | - #define SJSON_CPP_IMPL_NAMESPACE sjson |
| 74 | + // Namespace is inlined, its usage does not need to be qualified with the |
| 75 | + // full version everywhere |
| 76 | + #define SJSON_CPP_IMPL_NAMESPACE sjson |
58 | 77 |
|
59 | | - #define SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN \ |
60 | | - inline namespace SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME \ |
61 | | - { |
62 | | -#endif |
| 78 | + #define SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN \ |
| 79 | + inline namespace SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME \ |
| 80 | + { |
63 | 81 |
|
64 | | -#define SJSON_CPP_IMPL_VERSION_NAMESPACE_END \ |
65 | | - } |
| 82 | + #define SJSON_CPP_IMPL_VERSION_NAMESPACE_END \ |
| 83 | + } |
| 84 | +#endif |
0 commit comments