From da3ff59a272dafeabec4c26cffe883ee6e0bbaf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Rodr=C3=ADguez=20Troiti=C3=B1o?= Date: Tue, 9 Jul 2019 17:15:56 -0700 Subject: [PATCH] [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). --- stdlib/public/SwiftShims/LibcShims.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stdlib/public/SwiftShims/LibcShims.h b/stdlib/public/SwiftShims/LibcShims.h index 48ea170fb765b..a06808abe3105 100644 --- a/stdlib/public/SwiftShims/LibcShims.h +++ b/stdlib/public/SwiftShims/LibcShims.h @@ -23,6 +23,10 @@ #include "SwiftStddef.h" #include "Visibility.h" +#if defined(__ANDROID__) +#include +#endif + #if __has_feature(nullability) #pragma clang assume_nonnull begin #endif