Skip to content

Commit 5c95a07

Browse files
authored
Merge pull request #306 from gummif/gfa/detect-std
Problem: Missing detection of standards greater than C++11
2 parents d1e7c53 + 77575ce commit 5c95a07

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

zmq.hpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,37 @@
2626
#ifndef __ZMQ_HPP_INCLUDED__
2727
#define __ZMQ_HPP_INCLUDED__
2828

29-
#if (__cplusplus >= 201402L)
29+
// macros defined if has a specific standard or greater
30+
#if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1900)
31+
#define ZMQ_CPP11
32+
#endif
33+
#if (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
34+
#define ZMQ_CPP14
35+
#endif
36+
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
37+
#define ZMQ_CPP17
38+
#endif
39+
40+
#if defined(ZMQ_CPP14)
3041
#define ZMQ_DEPRECATED(msg) [[deprecated(msg)]]
3142
#elif defined(_MSC_VER)
3243
#define ZMQ_DEPRECATED(msg) __declspec(deprecated(msg))
3344
#elif defined(__GNUC__)
3445
#define ZMQ_DEPRECATED(msg) __attribute__((deprecated(msg)))
3546
#endif
3647

37-
#if (__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1900))
38-
#define ZMQ_CPP11
48+
#if defined(ZMQ_CPP17)
49+
#define ZMQ_NODISCARD [[nodiscard]]
50+
#else
51+
#define ZMQ_NODISCARD
52+
#endif
53+
54+
#if defined(ZMQ_CPP11)
3955
#define ZMQ_NOTHROW noexcept
4056
#define ZMQ_EXPLICIT explicit
4157
#define ZMQ_OVERRIDE override
4258
#define ZMQ_NULLPTR nullptr
4359
#else
44-
#define ZMQ_CPP03
4560
#define ZMQ_NOTHROW throw()
4661
#define ZMQ_EXPLICIT
4762
#define ZMQ_OVERRIDE

0 commit comments

Comments
 (0)