Swift / Clang error: module 'Glibc' has no member named 'stdout'

20 views
Skip to first unread message

Vlad Gorlov

unread,
Nov 29, 2020, 7:07:25 PM11/29/20
to android-ndk
Hi,

I am building Swift package "https://github.com/apple/swift-log" on macOS for Android using NDK 21.3.6528147 and getting errors shown below when targeting API 21:

```sh
error: module 'Glibc' has no member named 'stderr'
error: module 'Glibc' has no member named 'stdout'
```

As i understand clang not including `#define` directives (like `#define stdin (&__sF[0])` from `sysroot/usr/include/stdio.h`) when building `Glibc` clang module :0

Is there any workaround or solution how to `expose` stdin, stdout, and stderr to Swift (via clang module) ?

Thank you in advance!

* * *

To reproduce you can:


2. Create a file with following contents:
```swift
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
import Darwin
#elseif os(Windows)
import MSVCRT
#else
import Glibc
#endif

func test() {

   tolower(5) // sysroot/usr/include/ctype.h
   fesetround(6) // sysroot/usr/include/fenv.h
   localeconv() // sysroot/usr/include/locale.h
   #if os(Android)
   isnan(7) // sysroot/usr/include/math.h
   #endif

   #if os(Android)
   _ = Glibc.stderr!
   _ = Glibc.stdout!
   #endif

   //> sysroot/usr/include/stdio.h
   _ = FOPEN_MAX
   _ = off_t()
   clearerr(nil)
   fclose(nil)
   //<
}
```
3. Compile this file for API 23 (should be OK):

```sh

/.../swift-android-toolchain/usr/bin/swiftc-arm-linux-androideabi ./FILE.swift -v -Xcc -D__ANDROID_API__=23

```

4. Compile this file for API 21 (should be the errors):

```sh

/.../swift-android-toolchain/usr/bin/swiftc-arm-linux-androideabi ./FILE.swift -v -Xcc -D__ANDROID_API__=21

```

Reply all
Reply to author
Forward
0 new messages