2022-01-28 15:56:11 +01:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2023-01-28 10:16:34 +01:00
|
|
|
* Copyright (C) 2007-2023 Cppcheck team.
|
2022-01-28 15:56:11 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2013-09-04 20:59:49 +02:00
|
|
|
#ifndef configH
|
|
|
|
#define configH
|
2012-06-10 14:19:09 +02:00
|
|
|
|
2022-12-30 21:21:05 +01:00
|
|
|
#ifdef MAXTIME
|
|
|
|
#error "MAXTIME is no longer supported - please use command-line options --checks-max-time=, --template-max-time= and --typedef-max-time= instead"
|
|
|
|
#endif
|
|
|
|
|
2012-06-10 14:19:09 +02:00
|
|
|
#ifdef _WIN32
|
|
|
|
# ifdef CPPCHECKLIB_EXPORT
|
|
|
|
# define CPPCHECKLIB __declspec(dllexport)
|
|
|
|
# elif defined(CPPCHECKLIB_IMPORT)
|
|
|
|
# define CPPCHECKLIB __declspec(dllimport)
|
|
|
|
# else
|
|
|
|
# define CPPCHECKLIB
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# define CPPCHECKLIB
|
|
|
|
#endif
|
|
|
|
|
2014-03-26 16:43:12 +01:00
|
|
|
// MS Visual C++ memory leak debug tracing
|
2022-04-15 18:49:24 +02:00
|
|
|
#if !defined(DISABLE_CRTDBG_MAP_ALLOC) && defined(_MSC_VER) && defined(_DEBUG)
|
2014-03-26 16:43:12 +01:00
|
|
|
# define _CRTDBG_MAP_ALLOC
|
|
|
|
# include <crtdbg.h>
|
|
|
|
#endif
|
|
|
|
|
2023-11-15 15:31:12 +01:00
|
|
|
// 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
|
|
|
|
|
2020-02-13 16:27:06 +01:00
|
|
|
// C++11 noexcept
|
2023-11-15 15:31:12 +01:00
|
|
|
#if defined(__cpp_noexcept_function_type) || \
|
|
|
|
(defined(__GNUC__) && (__GNUC__ >= 5)) \
|
2022-05-15 12:42:29 +02:00
|
|
|
|| defined(__clang__) \
|
2021-08-07 20:51:18 +02:00
|
|
|
|| defined(__CPPCHECK__)
|
2020-02-13 16:27:06 +01:00
|
|
|
# define NOEXCEPT noexcept
|
|
|
|
#else
|
|
|
|
# define NOEXCEPT
|
|
|
|
#endif
|
|
|
|
|
2020-06-29 22:54:51 +02:00
|
|
|
// C++11 noreturn
|
2023-11-15 15:31:12 +01:00
|
|
|
#if __has_cpp_attribute (noreturn) \
|
|
|
|
|| (defined(__GNUC__) && (__GNUC__ >= 5)) \
|
2022-05-15 12:42:29 +02:00
|
|
|
|| defined(__clang__) \
|
2021-08-07 20:51:18 +02:00
|
|
|
|| defined(__CPPCHECK__)
|
2023-11-15 15:31:12 +01:00
|
|
|
# define NORETURN [[noreturn]]
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
# define NORETURN __attribute__((noreturn))
|
|
|
|
#else
|
|
|
|
# define NORETURN
|
2020-06-29 22:54:51 +02:00
|
|
|
#endif
|
|
|
|
|
2021-01-21 18:13:32 +01:00
|
|
|
// fallthrough
|
2023-11-15 15:31:12 +01:00
|
|
|
#if __cplusplus >= 201703L && __has_cpp_attribute (fallthrough)
|
|
|
|
# define FALLTHROUGH [[fallthrough]]
|
|
|
|
#elif defined(__clang__)
|
2021-01-21 18:13:32 +01:00
|
|
|
# define FALLTHROUGH [[clang::fallthrough]]
|
|
|
|
#elif (defined(__GNUC__) && (__GNUC__ >= 7))
|
|
|
|
# define FALLTHROUGH __attribute__((fallthrough))
|
|
|
|
#else
|
|
|
|
# define FALLTHROUGH
|
|
|
|
#endif
|
|
|
|
|
2022-05-15 12:42:29 +02:00
|
|
|
// unused
|
2023-11-15 15:31:12 +01:00
|
|
|
#if __cplusplus >= 201703L && __has_cpp_attribute (maybe_unused)
|
|
|
|
# define UNUSED [[maybe_unused]]
|
|
|
|
#elif defined(__GNUC__) \
|
2022-05-15 12:42:29 +02:00
|
|
|
|| defined(__clang__) \
|
|
|
|
|| defined(__CPPCHECK__)
|
|
|
|
# define UNUSED __attribute__((unused))
|
|
|
|
#else
|
|
|
|
# define UNUSED
|
|
|
|
#endif
|
|
|
|
|
2023-08-09 12:43:55 +02:00
|
|
|
// warn_unused
|
2023-11-15 15:31:12 +01:00
|
|
|
#if __has_cpp_attribute (gnu::warn_unused) || \
|
|
|
|
(defined(__clang__) && (__clang_major__ >= 15))
|
2023-08-09 12:43:55 +02:00
|
|
|
# define WARN_UNUSED [[gnu::warn_unused]]
|
|
|
|
#else
|
|
|
|
# define WARN_UNUSED
|
|
|
|
#endif
|
|
|
|
|
2020-02-13 16:27:06 +01:00
|
|
|
#define REQUIRES(msg, ...) class=typename std::enable_if<__VA_ARGS__::value>::type
|
|
|
|
|
2014-06-26 11:44:19 +02:00
|
|
|
#include <string>
|
|
|
|
static const std::string emptyString;
|
|
|
|
|
2022-02-11 19:44:08 +01:00
|
|
|
// Use the nonneg macro when you want to assert that a variable/argument is not negative
|
|
|
|
#ifdef __CPPCHECK__
|
|
|
|
#define nonneg __cppcheck_low__(0)
|
|
|
|
#elif defined(NONNEG)
|
|
|
|
// Enable non-negative values checking
|
|
|
|
// TODO : investigate using annotations/contracts for stronger value checking
|
|
|
|
#define nonneg unsigned
|
|
|
|
#else
|
|
|
|
// Disable non-negative values checking
|
|
|
|
#define nonneg
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if __has_feature(address_sanitizer)
|
|
|
|
#define ASAN 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ASAN
|
|
|
|
#ifdef __SANITIZE_ADDRESS__
|
|
|
|
#define ASAN 1
|
|
|
|
#else
|
|
|
|
#define ASAN 0
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2022-02-23 09:04:35 +01:00
|
|
|
#if defined(_WIN32)
|
|
|
|
#define THREADING_MODEL_THREAD
|
|
|
|
#define STDCALL __stdcall
|
|
|
|
#elif defined(USE_THREADS)
|
|
|
|
#define THREADING_MODEL_THREAD
|
|
|
|
#define STDCALL
|
2022-07-13 13:46:03 +02:00
|
|
|
#elif ((defined(__GNUC__) || defined(__sun)) && !defined(__MINGW32__)) || defined(__CPPCHECK__)
|
2022-02-23 09:04:35 +01:00
|
|
|
#define THREADING_MODEL_FORK
|
2022-07-08 16:42:57 +02:00
|
|
|
#define STDCALL
|
2022-02-23 09:04:35 +01:00
|
|
|
#else
|
|
|
|
#error "No threading model defined"
|
|
|
|
#endif
|
|
|
|
|
2022-03-30 19:30:02 +02:00
|
|
|
#define STRINGISIZE(...) #__VA_ARGS__
|
|
|
|
|
|
|
|
#ifdef __clang__
|
2023-08-16 19:35:53 +02:00
|
|
|
#define SUPPRESS_WARNING_PUSH(warning) _Pragma("clang diagnostic push") _Pragma(STRINGISIZE(clang diagnostic ignored warning))
|
|
|
|
#define SUPPRESS_WARNING_POP _Pragma("clang diagnostic pop")
|
|
|
|
#define SUPPRESS_WARNING_GCC_PUSH(warning)
|
|
|
|
#define SUPPRESS_WARNING_GCC_POP
|
|
|
|
#define SUPPRESS_WARNING_CLANG_PUSH(warning) SUPPRESS_WARNING_PUSH(warning)
|
|
|
|
#define SUPPRESS_WARNING_CLANG_POP SUPPRESS_WARNING_POP
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
#define SUPPRESS_WARNING_PUSH(warning) _Pragma("GCC diagnostic push") _Pragma(STRINGISIZE(GCC diagnostic ignored warning))
|
|
|
|
#define SUPPRESS_WARNING_POP _Pragma("GCC diagnostic pop")
|
|
|
|
#define SUPPRESS_WARNING_GCC_PUSH(warning) SUPPRESS_WARNING_PUSH(warning)
|
|
|
|
#define SUPPRESS_WARNING_GCC_POP SUPPRESS_WARNING_POP
|
|
|
|
#define SUPPRESS_WARNING_CLANG_PUSH(warning)
|
|
|
|
#define SUPPRESS_WARNING_CLANG_POP
|
2022-03-30 19:30:02 +02:00
|
|
|
#else
|
2023-08-16 19:35:53 +02:00
|
|
|
#define SUPPRESS_WARNING_PUSH(warning)
|
|
|
|
#define SUPPRESS_WARNING_POP
|
|
|
|
#define SUPPRESS_WARNING_GCC_PUSH(warning)
|
|
|
|
#define SUPPRESS_WARNING_GCC_POP
|
|
|
|
#define SUPPRESS_WARNING_CLANG_PUSH(warning)
|
|
|
|
#define SUPPRESS_WARNING_CLANG_POP
|
2022-03-30 19:30:02 +02:00
|
|
|
#endif
|
|
|
|
|
2022-08-20 20:54:31 +02:00
|
|
|
#if !defined(NO_WINDOWS_SEH) && defined(_WIN32) && defined(_MSC_VER)
|
2022-08-16 22:03:44 +02:00
|
|
|
#define USE_WINDOWS_SEH
|
|
|
|
#endif
|
|
|
|
|
2023-10-17 18:32:07 +02:00
|
|
|
// TODO: __GLIBC__ is dependent on the features.h include and not a built-in compiler define, so it might be problematic to depend on it
|
2022-08-16 22:03:44 +02:00
|
|
|
#if !defined(NO_UNIX_BACKTRACE_SUPPORT) && defined(__GNUC__) && defined(__GLIBC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__NetBSD__) && !defined(__SVR4) && !defined(__QNX__)
|
|
|
|
#define USE_UNIX_BACKTRACE_SUPPORT
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(NO_UNIX_SIGNAL_HANDLING) && defined(__GNUC__) && !defined(__MINGW32__) && !defined(__OS2__)
|
|
|
|
#define USE_UNIX_SIGNAL_HANDLING
|
|
|
|
#endif
|
2022-03-30 19:30:02 +02:00
|
|
|
|
2013-09-04 20:59:49 +02:00
|
|
|
#endif // configH
|