diff options
author | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2018-08-23 11:21:21 +0300 |
---|---|---|
committer | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2018-08-23 11:21:21 +0300 |
commit | d6b8e9a544792518613d98668277be29dc322274 (patch) | |
tree | bbb032bd10d87b573ae5d2fc59f09493be4052c8 | |
parent | ccc0c241c392f6a5d9206c504bdf3fd94b0a1b4f (diff) |
Print warning when used with NTKERNEL_ERROR_CATEGORY_INLINE=1
-rw-r--r-- | Readme.md | 6 | ||||
-rw-r--r-- | include/config.hpp | 9 | ||||
-rw-r--r-- | include/ntkernel_category.hpp | 2 |
3 files changed, 11 insertions, 6 deletions
@@ -11,9 +11,9 @@ on Windows (i.e. the `GetLastError()` error code space). - Implements mapped comparisons to error conditions of `std::generic_category` on all platforms (i.e. the POSIX `errno` error code space). - Comes in three implementation variants: - - Header-only table (`NTKERNEL_ERROR_CATEGORY_INLINE`). - - Static library table (`NTKERNEL_ERROR_CATEGORY_STATIC`). - - Shared library table. + - Header-only table (`NTKERNEL_ERROR_CATEGORY_INLINE=1`). + - Static library table (`NTKERNEL_ERROR_CATEGORY_STATIC=1`). + - Shared library table (the default). The default of `NTKERNEL_ERROR_CATEGORY_STATIC` and `NTKERNEL_ERROR_CATEGORY_INLINE` both NOT being defined means that the shared library table is the default. As diff --git a/include/config.hpp b/include/config.hpp index 2c1d4aa..be9cfd6 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -25,7 +25,7 @@ http://www.boost.org/LICENSE_1_0.txt) #ifndef NTKERNEL_CATEGORY_CONFIG_HPP #define NTKERNEL_CATEGORY_CONFIG_HPP -#ifdef NTKERNEL_ERROR_CATEGORY_STATIC +#if NTKERNEL_ERROR_CATEGORY_STATIC #define NTKERNEL_ERROR_CATEGORY_API extern #else #ifdef _WIN32 @@ -43,8 +43,13 @@ http://www.boost.org/LICENSE_1_0.txt) #endif #endif -#ifdef NTKERNEL_ERROR_CATEGORY_INLINE +#if NTKERNEL_ERROR_CATEGORY_INLINE #define NTKERNEL_ERROR_CATEGORY_INLINE_API inline +#ifdef _MSC_VER +#pragma message("WARNING: Defining custom error code category ntkernel_category() via header only form is unreliable! Semantic comparisons will break! Define NTKERNEL_ERROR_CATEGORY_INLINE to 0 and only ever link in ntkernel_category() from a prebuilt shared library to avoid this problem.") +#else +#warning WARNING: Defining custom error code category ntkernel_category() via header only form is unreliable! Semantic comparisons will break! Define NTKERNEL_ERROR_CATEGORY_INLINE to 0 and only ever link in ntkernel_category() from a prebuilt shared library to avoid this problem. +#endif #else #define NTKERNEL_ERROR_CATEGORY_INLINE_API #endif diff --git a/include/ntkernel_category.hpp b/include/ntkernel_category.hpp index 6df0a12..4d6abb8 100644 --- a/include/ntkernel_category.hpp +++ b/include/ntkernel_category.hpp @@ -34,7 +34,7 @@ namespace ntkernel_error_category NTKERNEL_ERROR_CATEGORY_API NTKERNEL_ERROR_CATEGORY_INLINE_API const std::error_category &ntkernel_category() noexcept; } -#ifdef NTKERNEL_ERROR_CATEGORY_INLINE +#if NTKERNEL_ERROR_CATEGORY_INLINE #include "detail/ntkernel_category_impl.ipp" #endif |