Skip to content

Commit 43f831b

Browse files
janicduplessisfacebook-github-bot
authored andcommitted
Make all headers public and add #ifdef __cplusplus (#1150)
Summary: This change is mostly needed to support the new react-native architecture with Swift. Some private yoga headers end up being included in the swift build and result in compilation failure since swift cannot compile c++ modules. See #33381. The most reliable fix is to include all headers as public headers, and add `#ifdef __cplusplus` to those that include c++. This is already what we do for other headers, this applies this to all headers. Tested in the YogaKitSample, and also in a react-native app. Changelog: [iOS] [Changed] - Make all Yoga headers public and add #ifdef __cplusplus X-link: facebook/yoga#1150 Reviewed By: dmitryrykun Differential Revision: D36966687 Pulled By: cortinico fbshipit-source-id: a34a54d56df43ab4934715070bab8e790b9abd39
1 parent 9ef3045 commit 43f831b

9 files changed

+43
-0
lines changed

ReactCommon/yoga/yoga/BitUtils.h

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#ifdef __cplusplus
11+
1012
#include <cstdio>
1113
#include <cstdint>
1214
#include "YGEnums.h"
@@ -65,3 +67,5 @@ inline void setBooleanData(uint8_t& flags, size_t index, bool value) {
6567
} // namespace detail
6668
} // namespace yoga
6769
} // namespace facebook
70+
71+
#endif

ReactCommon/yoga/yoga/CompactValue.h

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#ifdef __cplusplus
11+
1012
#include "YGValue.h"
1113
#include "YGMacros.h"
1214
#include <cmath>
@@ -182,3 +184,5 @@ constexpr bool operator!=(CompactValue a, CompactValue b) noexcept {
182184
} // namespace detail
183185
} // namespace yoga
184186
} // namespace facebook
187+
188+
#endif

ReactCommon/yoga/yoga/Utils.h

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77

88
#pragma once
9+
10+
#ifdef __cplusplus
11+
912
#include "YGNode.h"
1013
#include "Yoga-internal.h"
1114
#include "CompactValue.h"
@@ -145,3 +148,5 @@ inline YGFloatOptional YGResolveValueMargin(
145148
}
146149

147150
void throwLogicalErrorWithMessage(const char* message);
151+
152+
#endif

ReactCommon/yoga/yoga/YGConfig.h

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77

88
#pragma once
9+
10+
#ifdef __cplusplus
11+
912
#include "Yoga-internal.h"
1013
#include "Yoga.h"
1114

@@ -74,3 +77,5 @@ struct YOGA_EXPORT YGConfig {
7477
setCloneNodeCallback(YGCloneNodeFunc{nullptr});
7578
}
7679
};
80+
81+
#endif

ReactCommon/yoga/yoga/YGFloatOptional.h

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#ifdef __cplusplus
11+
1012
#include <cmath>
1113
#include <limits>
1214
#include "Yoga-internal.h"
@@ -68,3 +70,5 @@ inline bool operator>=(YGFloatOptional lhs, YGFloatOptional rhs) {
6870
inline bool operator<=(YGFloatOptional lhs, YGFloatOptional rhs) {
6971
return lhs < rhs || lhs == rhs;
7072
}
73+
74+
#endif

ReactCommon/yoga/yoga/YGLayout.h

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77

88
#pragma once
9+
10+
#ifdef __cplusplus
11+
912
#include "BitUtils.h"
1013
#include "YGFloatOptional.h"
1114
#include "Yoga-internal.h"
@@ -85,3 +88,5 @@ struct YGLayout {
8588
bool operator==(YGLayout layout) const;
8689
bool operator!=(YGLayout layout) const { return !(*this == layout); }
8790
};
91+
92+
#endif

ReactCommon/yoga/yoga/YGNodePrint.h

+7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
*/
77

88
#ifdef DEBUG
9+
910
#pragma once
11+
12+
#ifdef __cplusplus
13+
1014
#include <string>
1115

1216
#include "Yoga.h"
@@ -22,4 +26,7 @@ void YGNodeToString(
2226

2327
} // namespace yoga
2428
} // namespace facebook
29+
30+
#endif
31+
2532
#endif

ReactCommon/yoga/yoga/Yoga-internal.h

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77

88
#pragma once
9+
10+
#ifdef __cplusplus
11+
912
#include <algorithm>
1013
#include <array>
1114
#include <cmath>
@@ -148,3 +151,5 @@ static const float kDefaultFlexShrink = 0.0f;
148151
static const float kWebDefaultFlexShrink = 1.0f;
149152

150153
extern bool YGFloatsEqual(const float a, const float b);
154+
155+
#endif

ReactCommon/yoga/yoga/log.h

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#ifdef __cplusplus
11+
1012
#include "YGEnums.h"
1113

1214
struct YGNode;
@@ -36,3 +38,5 @@ struct Log {
3638
} // namespace detail
3739
} // namespace yoga
3840
} // namespace facebook
41+
42+
#endif

0 commit comments

Comments
 (0)