I'm getting `platform.posix.TIOCGWINSZ` showing up...
# kotlin-native
d
I'm getting
platform.posix.TIOCGWINSZ
showing up as undefined on macos. But as far as I can tell, that constant should be supported on the mac platform?
What's weird is when I try to compile my code on a CI, it fails. But when I compile it on an old MBP I have lying around, compilation works. (But the IDE shows the symbol as unresolvable)
Here's the code:
Copy code
val numColumns = memScoped {
    val winsize = alloc<winsize>()
    ioctl(STDOUT_FILENO, TIOCGWINSZ, winsize.ptr)
    winsize.ws_col.toInt()
}
winsize
and
ioctl
are found correctly.
Note that this code lives in
posixMain
, not
macosMain
or anything more specific, in case that's what's causing the problem?
(And in my project I target both macos x64 and macos arm64)
I believe I've solved the issue. My CI is building at least. I suspect what is happening here is that the
TIOCGWINSZ
constant provided by Linux is different from
TIOCGWINSZ
provided by Mac, so that the intersection stdlib provided at the
posixMain
parent layer excludes it. I am using expect / actual machinery to work around the issue: https://github.com/varabyte/kotter/commit/02174741b1876d16a8640e4067b8cea42c141d62 (☝️ Basically, both
macosMain
and
linuxMain
provide exactly the same
actual val TIOCGWINSZ: ULong = platform.posix.TIOCGWINSZ
code, but K/N can resolve the constant correctly at those lower levels)