[Yoga] fix error: templates must have C++ linkage

This commit is contained in:
vvveiii
2020-08-14 14:35:21 +08:00
parent b5b42bd6c5
commit 520b622e5c
4 changed files with 12 additions and 0 deletions

View File

@@ -10,6 +10,7 @@
#include "YGMacros.h"
#ifdef __cplusplus
YG_EXTERN_CXX_BEGIN
namespace facebook {
namespace yoga {
namespace enums {
@@ -27,6 +28,7 @@ constexpr int n() {
} // namespace enums
} // namespace yoga
} // namespace facebook
YG_EXTERN_C_END
#endif
#define YG_ENUM_DECL(NAME, ...) \
@@ -37,6 +39,7 @@ constexpr int n() {
#define YG_ENUM_SEQ_DECL(NAME, ...) \
YG_ENUM_DECL(NAME, __VA_ARGS__) \
YG_EXTERN_C_END \
YG_EXTERN_CXX_BEGIN \
namespace facebook { \
namespace yoga { \
namespace enums { \
@@ -47,6 +50,7 @@ constexpr int n() {
} \
} \
} \
YG_EXTERN_C_END \
YG_EXTERN_C_BEGIN
#else
#define YG_ENUM_SEQ_DECL YG_ENUM_DECL

View File

@@ -8,9 +8,11 @@
#pragma once
#ifdef __cplusplus
#define YG_EXTERN_CXX_BEGIN extern "C++" {
#define YG_EXTERN_C_BEGIN extern "C" {
#define YG_EXTERN_C_END }
#else
#define YG_EXTERN_CXX_BEGIN
#define YG_EXTERN_C_BEGIN
#define YG_EXTERN_C_END
#endif

View File

@@ -15,8 +15,10 @@
#define COMPILING_WITH_CLANG_ON_WINDOWS
#endif
#if defined(COMPILING_WITH_CLANG_ON_WINDOWS)
YG_EXTERN_CXX_BEGIN
#include <limits>
constexpr float YGUndefined = std::numeric_limits<float>::quiet_NaN();
YG_EXTERN_C_END
#else
YG_EXTERN_C_BEGIN
@@ -44,6 +46,7 @@ YG_EXTERN_C_END
#undef COMPILING_WITH_CLANG_ON_WINDOWS
#ifdef __cplusplus
YG_EXTERN_CXX_BEGIN
inline bool operator==(const YGValue& lhs, const YGValue& rhs) {
if (lhs.unit != rhs.unit) {
@@ -92,4 +95,5 @@ inline YGValue operator"" _percent(unsigned long long value) {
} // namespace yoga
} // namespace facebook
YG_EXTERN_C_END
#endif

View File

@@ -360,6 +360,7 @@ WIN_EXPORT float YGRoundValueToPixelGrid(
YG_EXTERN_C_END
#ifdef __cplusplus
YG_EXTERN_CXX_BEGIN
#include <functional>
#include <vector>
@@ -371,4 +372,5 @@ void YGTraversePreOrder(
void YGNodeSetChildren(YGNodeRef owner, const std::vector<YGNodeRef>& children);
YG_EXTERN_C_END
#endif