config.h: improved and cleaned up some preprocessor checks (#5663)
This commit is contained in:
parent
e7f8985173
commit
d3a8eb1ae2
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
|
|
||||||
// Provide own translations for standard buttons. This (garbage) code is needed to enforce them to appear in .ts files even after "lupdate gui.pro"
|
// Provide own translations for standard buttons. This (garbage) code is needed to enforce them to appear in .ts files even after "lupdate gui.pro"
|
||||||
static UNUSED void unused()
|
UNUSED static void unused()
|
||||||
{
|
{
|
||||||
Q_UNUSED(QT_TRANSLATE_NOOP("QPlatformTheme", "OK"))
|
Q_UNUSED(QT_TRANSLATE_NOOP("QPlatformTheme", "OK"))
|
||||||
Q_UNUSED(QT_TRANSLATE_NOOP("QPlatformTheme", "Cancel"))
|
Q_UNUSED(QT_TRANSLATE_NOOP("QPlatformTheme", "Cancel"))
|
||||||
|
|
53
lib/config.h
53
lib/config.h
|
@ -41,8 +41,26 @@
|
||||||
# include <crtdbg.h>
|
# include <crtdbg.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// compatibility macros
|
||||||
|
#ifndef __has_builtin
|
||||||
|
#define __has_builtin(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __has_include
|
||||||
|
#define __has_include(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __has_cpp_attribute
|
||||||
|
#define __has_cpp_attribute(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __has_feature
|
||||||
|
#define __has_feature(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
// C++11 noexcept
|
// C++11 noexcept
|
||||||
#if (defined(__GNUC__) && (__GNUC__ >= 5)) \
|
#if defined(__cpp_noexcept_function_type) || \
|
||||||
|
(defined(__GNUC__) && (__GNUC__ >= 5)) \
|
||||||
|| defined(__clang__) \
|
|| defined(__clang__) \
|
||||||
|| defined(__CPPCHECK__)
|
|| defined(__CPPCHECK__)
|
||||||
# define NOEXCEPT noexcept
|
# define NOEXCEPT noexcept
|
||||||
|
@ -51,25 +69,21 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// C++11 noreturn
|
// C++11 noreturn
|
||||||
#if defined __has_cpp_attribute
|
#if __has_cpp_attribute (noreturn) \
|
||||||
# if __has_cpp_attribute (noreturn)
|
|| (defined(__GNUC__) && (__GNUC__ >= 5)) \
|
||||||
# define NORETURN [[noreturn]]
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if !defined(NORETURN)
|
|
||||||
# if (defined(__GNUC__) && (__GNUC__ >= 5)) \
|
|
||||||
|| defined(__clang__) \
|
|| defined(__clang__) \
|
||||||
|| defined(__CPPCHECK__)
|
|| defined(__CPPCHECK__)
|
||||||
# define NORETURN [[noreturn]]
|
# define NORETURN [[noreturn]]
|
||||||
# elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
# define NORETURN __attribute__((noreturn))
|
# define NORETURN __attribute__((noreturn))
|
||||||
# else
|
#else
|
||||||
# define NORETURN
|
# define NORETURN
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// fallthrough
|
// fallthrough
|
||||||
#if defined(__clang__)
|
#if __cplusplus >= 201703L && __has_cpp_attribute (fallthrough)
|
||||||
|
# define FALLTHROUGH [[fallthrough]]
|
||||||
|
#elif defined(__clang__)
|
||||||
# define FALLTHROUGH [[clang::fallthrough]]
|
# define FALLTHROUGH [[clang::fallthrough]]
|
||||||
#elif (defined(__GNUC__) && (__GNUC__ >= 7))
|
#elif (defined(__GNUC__) && (__GNUC__ >= 7))
|
||||||
# define FALLTHROUGH __attribute__((fallthrough))
|
# define FALLTHROUGH __attribute__((fallthrough))
|
||||||
|
@ -78,7 +92,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// unused
|
// unused
|
||||||
#if defined(__GNUC__) \
|
#if __cplusplus >= 201703L && __has_cpp_attribute (maybe_unused)
|
||||||
|
# define UNUSED [[maybe_unused]]
|
||||||
|
#elif defined(__GNUC__) \
|
||||||
|| defined(__clang__) \
|
|| defined(__clang__) \
|
||||||
|| defined(__CPPCHECK__)
|
|| defined(__CPPCHECK__)
|
||||||
# define UNUSED __attribute__((unused))
|
# define UNUSED __attribute__((unused))
|
||||||
|
@ -87,7 +103,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// warn_unused
|
// warn_unused
|
||||||
#if (defined(__clang__) && (__clang_major__ >= 15))
|
#if __has_cpp_attribute (gnu::warn_unused) || \
|
||||||
|
(defined(__clang__) && (__clang_major__ >= 15))
|
||||||
# define WARN_UNUSED [[gnu::warn_unused]]
|
# define WARN_UNUSED [[gnu::warn_unused]]
|
||||||
#else
|
#else
|
||||||
# define WARN_UNUSED
|
# define WARN_UNUSED
|
||||||
|
@ -110,11 +127,9 @@ static const std::string emptyString;
|
||||||
#define nonneg
|
#define nonneg
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__has_feature)
|
|
||||||
#if __has_feature(address_sanitizer)
|
#if __has_feature(address_sanitizer)
|
||||||
#define ASAN 1
|
#define ASAN 1
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ASAN
|
#ifndef ASAN
|
||||||
#ifdef __SANITIZE_ADDRESS__
|
#ifdef __SANITIZE_ADDRESS__
|
||||||
|
|
|
@ -19,13 +19,7 @@
|
||||||
#ifndef sourcelocationH
|
#ifndef sourcelocationH
|
||||||
#define sourcelocationH
|
#define sourcelocationH
|
||||||
|
|
||||||
#ifndef __has_builtin
|
#include "config.h"
|
||||||
#define __has_builtin(x) 0 // Compatibility with non-clang compilers.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __has_include
|
|
||||||
#define __has_include(x) 0 // Compatibility with non-clang compilers.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __CPPCHECK__
|
#ifdef __CPPCHECK__
|
||||||
#define CPPCHECK_HAS_SOURCE_LOCATION 0
|
#define CPPCHECK_HAS_SOURCE_LOCATION 0
|
||||||
|
|
Loading…
Reference in New Issue