Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-04-16 00:45:13 +0300
committerJulian Eisel <julian@blender.org>2021-06-14 20:00:13 +0300
commitaadd3550289aa0258e9e99864bc6063d0dd03460 (patch)
treef531edd49f26e8a6000fc2ee7886b684d5096fb7 /source/blender/blenlib/BLI_utildefines.h
parent3de6fe0b3eebb2af66db8051fbb65a49e49a8578 (diff)
Fix possible C-linkage warning on Clang
The warning would appear when using the `ENUM_OPERATORS()` macro inside of an `extern "C"` block. Didn't cause a warning in master currently, but in the `asset-browser-poselib` branch. After macro expansion, there would be C++ code in code with C linkage (`extern "C"`). So make sure the expanded C++ code always uses C++ linkage. The syntax used is totally C++ compliant: the C++ standard requires that in such nested linkage specifications, the innermost one determines the linking language (e.g. see https://timsong-cpp.github.io/cppwp/n4659/dcl.link#4).
Diffstat (limited to 'source/blender/blenlib/BLI_utildefines.h')
-rw-r--r--source/blender/blenlib/BLI_utildefines.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index 1c6e6ffe578..0bf117df43b 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -785,6 +785,7 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
* To use after the enum declaration. */
/* If any enumerator `C` is set to say `A|B`, then `C` would be the max enum value. */
# define ENUM_OPERATORS(_enum_type, _max_enum_value) \
+ extern "C++" { \
inline constexpr _enum_type operator|(_enum_type a, _enum_type b) \
{ \
return static_cast<_enum_type>(static_cast<int>(a) | b); \
@@ -804,7 +805,8 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
inline _enum_type &operator&=(_enum_type &a, _enum_type b) \
{ \
return a = static_cast<_enum_type>(static_cast<int>(a) & b); \
- }
+ } \
+ } /* extern "C++" */
#else
/* Output nothing. */