Skip to content

Commit ca2314f

Browse files
committed
Fix OG_COUNTED_BY issue on Linux and macOS
1 parent 0d44ba0 commit ca2314f

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/OpenGraph_SPI/include/OGBase.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,19 @@
4343
#define OG_CONSTEXPR
4444
#endif
4545

46+
#if __has_include(<ptrcheck.h>) // Fix conflict define issue of the SDK
47+
#include <ptrcheck.h>
48+
#define OG_COUNTED_BY(N) __counted_by(N)
49+
#else
4650
#if !defined(__counted_by)
4751
#if __has_attribute(__counted_by__)
4852
#define __counted_by(N) __attribute__((__counted_by__(N)))
4953
#else
5054
#define __counted_by(N)
5155
#endif
5256
#endif
53-
5457
#define OG_COUNTED_BY(N) __counted_by(N)
58+
#endif
5559

5660
#include "OGSwiftSupport.h"
5761
#include "OGTargetConditionals.h"

Sources/OpenGraph_SPI/include/OGGraph.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,18 @@ OG_EXPORT
103103
OG_REFINED_FOR_SWIFT
104104
void OGGraphSetNeedsUpdate(OGGraphRef graph) OG_SWIFT_NAME(OGGraphRef.setNeedsUpdate(self:));
105105

106-
// TODO: Add OG_COUNTED_BY later https://github.com/OpenSwiftUIProject/OpenGraph/issues/130
106+
#if OG_TARGET_OS_DARWIN
107+
OG_EXPORT
108+
//OG_REFINED_FOR_SWIFT
109+
bool OGGraphAnyInputsChanged(const OGAttribute *inputs OG_COUNTED_BY(count), size_t count);
110+
#else
111+
// __counted_by__ is supported with Swift 6.1+ toolchain's clang on Linux.
112+
// But it required the count to be declared first which is not required on Apple clang.
113+
// See https://github.com/OpenSwiftUIProject/OpenGraph/issues/130
107114
OG_EXPORT
108115
OG_REFINED_FOR_SWIFT
109116
bool OGGraphAnyInputsChanged(const OGAttribute *inputs, size_t count);
117+
#endif
110118

111119
OG_EXTERN_C_END
112120

0 commit comments

Comments
 (0)