Skip to content

Commit

Permalink
common/Compiler: only define language keyword definitions if undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Jun 15, 2024
1 parent 70406df commit c1498e9
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/common/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,26 +226,34 @@ definition to detect its implementation was only added in C++17. */
#define NOEXCEPT noexcept
#define NOEXCEPT_IF(x) noexcept(x)
#define NOEXCEPT_EXPR(x) noexcept(x)
#else
#define NOEXCEPT
#define NOEXCEPT_IF(x)
#define NOEXCEPT_EXPR(x) x
#endif

// Uses SD-6 Feature Test Recommendations
#if defined(__cpp_constexpr)
#define CONSTEXPR constexpr
#define CONSTEXPR_FUNCTION constexpr

#if __cpp_constexpr >= 201304
#define CONSTEXPR_FUNCTION_RELAXED constexpr
#else
#define CONSTEXPR_FUNCTION_RELAXED
#endif
#else
// Work around lack of constexpr
#endif

// Work around lack of language keywords.
#if !defined(NOEXCEPT)
#define NOEXCEPT
#endif
#if !defined(NOEXCEPT_IF)
#define NOEXCEPT_IF(x)
#endif
#if !defined(NOEXCEPT_EXPR)
#define NOEXCEPT_EXPR(x) x
#endif
#if !defined(CONSTEXPR)
#define CONSTEXPR
#endif
#if !defined(CONSTEXPR_FUNCTION)
#define CONSTEXPR_FUNCTION
#endif
#if !defined(CONSTEXPR_FUNCTION_RELAXED)
#define CONSTEXPR_FUNCTION_RELAXED
#endif

Expand Down

0 comments on commit c1498e9

Please sign in to comment.