Hi,
I'm trying to do some stuff with ncurses (for now, import Darwin.ncurses
, but that will have to change if I do other platforms). I'm using Swift 6, and I'm getting some errors when I try and get the dimensions of the terminal:
class Console {
var size: Point { return Point(Int(getmaxx(stdscr)), Int(getmaxy(stdscr))) }
}
Reference to var 'stdscr' is not concurrency-safe because it involves shared mutable state
Which is true. I've not sat down and fully comes to terms with the new concurrency stuff. But this is a single threaded affair, and I'm quite happy to restrict access to the console to a single thread.
The problem I'm running into is that it seems like I'd have to annotate the global variable itself, which I can't do. I can make the error go away by storing the pointer to stdscr
that initscr
returns, and then mark the Console
class as @MainActor
to ensure everything is above board (if my understanding is accurate).
Is there a way to annotate global variables from another package that I've missed, or is make-a-copy-and-annotate-that the way to go?