summaryrefslogtreecommitdiffhomepage
path: root/compat/macros.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-06-26 22:25:22 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-06-26 23:05:21 +0200
commitd65936200a2756e6619a109fa6fa673b91df802e (patch)
tree80b6b6fc7ba9023cbe47290b8ae1bc5468a19bb1 /compat/macros.hpp
parent4046773c41ee3c0f65840828ab983cfd13451c85 (diff)
modernize C++ syntax
No visible changes (hopefully).
Diffstat (limited to 'compat/macros.hpp')
-rw-r--r--compat/macros.hpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/compat/macros.hpp b/compat/macros.hpp
index 761da0b1..61c49975 100644
--- a/compat/macros.hpp
+++ b/compat/macros.hpp
@@ -2,21 +2,17 @@
#if defined _MSC_VER
# define cc_noinline __declspec(noinline)
-#elif defined __GNUG__
-# define cc_noinline __attribute__((noinline))
#else
-# define cc_noinline
+# define cc_noinline __attribute__((noinline))
#endif
#if defined _MSC_VER
# define cc_forceinline __forceinline
#else
-# define cc_forceinline __attribute__((always_inline, gnu_inline)) inline
+# define cc_forceinline __attribute__((always_inline))
#endif
-#ifdef Q_CREATOR_RUN
-# define cc_warn_unused_result
-#elif defined _MSC_VER
+#if defined _MSC_VER
# define cc_warn_unused_result _Check_return_
#else
# define cc_warn_unused_result __attribute__((warn_unused_result))
@@ -40,15 +36,17 @@
#if !defined PP_CAT
# define PP_CAT(x,y) PP_CAT1(x,y)
-# define PP_CAT1(x,y) x##y
+# define PP_CAT1(x,y) PP_CAT2(x,y)
+# define PP_CAT2(x,y) x ## y
#endif
-#define once_only(...) do { static bool once__ = false; if (!once__) { once__ = true; __VA_ARGS__; } } while(false)
-
#if defined __cplusplus
// from now only C++
+//#define once_only(...) do { static bool once__ = false; if (!once__) { once__ = true; __VA_ARGS__; } } while(false)
+#define once_only(expr) ([&] { static decltype(auto) ret___1132 = (expr); return ret___1132; }())
+
#include <type_traits>
template<typename t>
@@ -66,7 +64,7 @@ constexpr cc_forceinline void static_warn<true>() {}
static_warn<(cond)>(); \
#define progn(...) (([&] { __VA_ARGS__ })())
-#define prog1(x, ...) (([&] { auto _ret1324 = (x); do { __VA_ARGS__; } while (0); return _ret1324; })())
+#define prog1(x, ...) (([&] { decltype(auto) ret1324 = (x); __VA_ARGS__; return ret1324; })())
// end c++-only macros
#endif