Merge pull request #1551 from heavywatal/fix-1535-nodiscard-clang
Remove C++17 extension warning from clang; #1535
This commit is contained in:
		
						commit
						b52c3638f5
					
				
					 2 changed files with 26 additions and 18 deletions
				
			
		|  | @ -18,6 +18,14 @@ | |||
|     #endif | ||||
| #endif | ||||
| 
 | ||||
| // C++ language standard detection
 | ||||
| #if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
 | ||||
|     #define JSON_HAS_CPP_17 | ||||
|     #define JSON_HAS_CPP_14 | ||||
| #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) | ||||
|     #define JSON_HAS_CPP_14 | ||||
| #endif | ||||
| 
 | ||||
| // disable float-equal warnings on GCC/clang
 | ||||
| #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) | ||||
|     #pragma GCC diagnostic push | ||||
|  | @ -42,7 +50,11 @@ | |||
| // allow for portable nodiscard warnings
 | ||||
| #if defined(__has_cpp_attribute) | ||||
|     #if __has_cpp_attribute(nodiscard) | ||||
|         #define JSON_NODISCARD [[nodiscard]] | ||||
|         #if defined(__clang__) && !defined(JSON_HAS_CPP_17) // issue #1535
 | ||||
|             #define JSON_NODISCARD | ||||
|         #else | ||||
|             #define JSON_NODISCARD [[nodiscard]] | ||||
|         #endif | ||||
|     #elif __has_cpp_attribute(gnu::warn_unused_result) | ||||
|         #define JSON_NODISCARD [[gnu::warn_unused_result]] | ||||
|     #else | ||||
|  | @ -95,14 +107,6 @@ | |||
|     #define JSON_UNLIKELY(x)    x | ||||
| #endif | ||||
| 
 | ||||
| // C++ language standard detection
 | ||||
| #if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
 | ||||
|     #define JSON_HAS_CPP_17 | ||||
|     #define JSON_HAS_CPP_14 | ||||
| #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) | ||||
|     #define JSON_HAS_CPP_14 | ||||
| #endif | ||||
| 
 | ||||
| /*!
 | ||||
| @brief macro to briefly define a mapping between an enum and JSON | ||||
| @def NLOHMANN_JSON_SERIALIZE_ENUM | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue