Skip to content

Commit da3ff59

Browse files
committed
[android] Include api-level.h for Android and C++ interop.
When the header was used in Android, the usage of __ANDROID_API__ was not set if the compiler wasn't setting it externally. There was a check for __ANDROID_API__, which defaulted to zero, and so it didn't pass. The external function definition was not being done, but in C mode, it didn't matter because implicit functions are allowed. That's not true in C++ mode, which fails to compile any code that tries to include this header. The solution is including android/api-level.h which will define __ANDROID_API__ to a very high value if it is not defined already (which is the default behaviour in the NDK).
1 parent 3924d1a commit da3ff59

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

stdlib/public/SwiftShims/LibcShims.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
#include "SwiftStddef.h"
2424
#include "Visibility.h"
2525

26+
#if defined(__ANDROID__)
27+
#include <android/api-level.h>
28+
#endif
29+
2630
#if __has_feature(nullability)
2731
#pragma clang assume_nonnull begin
2832
#endif

0 commit comments

Comments
 (0)