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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

Vlad Gorlov
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:

1. Download Swift Toolchain for Android "https://github.com/vgorloff/swift-everywhere-toolchain/releases/tag/1.0.65"

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

```

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/1f57be3c-7bb9-4978-b548-7bac387bd253n%40googlegroups.com.