From ffc1a3ef65400eb4d4c3db005092a1c3b68e7eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rombauts?= Date: Tue, 14 Jan 2020 09:47:43 +0100 Subject: [PATCH] Fix the SQLITECPP_PURE_FUNC macro to actually use the correct "pure" attribute --- include/SQLiteCpp/Statement.h | 27 +-------------------------- include/SQLiteCpp/Utils.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 26 deletions(-) create mode 100644 include/SQLiteCpp/Utils.h diff --git a/include/SQLiteCpp/Statement.h b/include/SQLiteCpp/Statement.h index 772e76c3..5d6a73c0 100644 --- a/include/SQLiteCpp/Statement.h +++ b/include/SQLiteCpp/Statement.h @@ -11,37 +11,12 @@ #pragma once #include +#include // SQLITECPP_PURE_FUNC #include #include #include // For INT_MAX -// some macros are taken from https://github.com/nemequ/hedley/blob/master/hedley.h , it was public domain that time -#if defined(__GNUC__) || defined(__GNUG__) || defined(__clang__) ||\ -(defined(__INTEL_COMPILER) && __INTEL_COMPILER > 1600) ||\ -(defined(__ARMCC_VERSION) && __ARMCC_VERSION > 4010000) ||\ -(\ - defined(__TI_COMPILER_VERSION__) && (\ - __TI_COMPILER_VERSION__ > 8003000 ||\ - (__TI_COMPILER_VERSION__ > 7003000 && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))\ - )\ -) - #if defined(__has_attribute) - #if !defined(SQLITECPP_PURE_FUNC) && __has_attribute(const) - #define SQLITECPP_PURE_FUNC __attribute__((const)) - #endif - #endif -#endif -#if !defined(SQLITECPP_PURE_FUNC) - #define SQLITECPP_PURE_FUNC - #if defined(__GNUC__) || defined(__GNUG__) || defined(__clang__) - #warning "You have a compiler without the needed macros or attributes. Cannot detect and apply support of pure const functions. Efficiency likely will be harmed. Consider using another compiler or its version" - #elif _MSC_VER - #pragma message "You have a compiler without the needed macros or attributes. Cannot detect and apply support of pure const functions. Efficiency likely will be harmed. Consider using another compiler or its version" - #endif -#endif - - // Forward declarations to avoid inclusion of in a header struct sqlite3; struct sqlite3_stmt; diff --git a/include/SQLiteCpp/Utils.h b/include/SQLiteCpp/Utils.h new file mode 100644 index 00000000..f053b3f1 --- /dev/null +++ b/include/SQLiteCpp/Utils.h @@ -0,0 +1,31 @@ +/** + * @file Utils.h + * @ingroup SQLiteCpp + * @brief Definition of the SQLITECPP_PURE_FUNC macro. + * + * Copyright (c) 2012-2020 Sebastien Rombauts (sebastien.rombauts@gmail.com) + * + * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt + * or copy at http://opensource.org/licenses/MIT) + */ +#pragma once + +// macro taken from https://github.com/nemequ/hedley/blob/master/hedley.h that was in public domain at this time +#if defined(__GNUC__) || defined(__GNUG__) || defined(__clang__) ||\ +(defined(__INTEL_COMPILER) && __INTEL_COMPILER > 1600) ||\ +(defined(__ARMCC_VERSION) && __ARMCC_VERSION > 4010000) ||\ +(\ + defined(__TI_COMPILER_VERSION__) && (\ + __TI_COMPILER_VERSION__ > 8003000 ||\ + (__TI_COMPILER_VERSION__ > 7003000 && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))\ + )\ +) +#if defined(__has_attribute) +#if !defined(SQLITECPP_PURE_FUNC) && __has_attribute(pure) +#define SQLITECPP_PURE_FUNC __attribute__((pure)) +#endif +#endif +#endif +#if !defined(SQLITECPP_PURE_FUNC) +#define SQLITECPP_PURE_FUNC +#endif