rjeczalik / notify

File system event notification library on steroids.
MIT License
900 stars 128 forks source link

C.FSEventStreamScheduleWithRunLoop(ref, runloop, C.kCFRunLoopDefaultMode) MacOS 13 future remove #212

Closed yantianlei closed 1 year ago

yantianlei commented 1 year ago

cgo-gcc-prolog:217:2: warning: 'FSEventStreamScheduleWithRunLoop' is deprecated: first deprecated in macOS 13.0 - Use FSEventStreamSetDispatchQueue instead. [-Wdeprecated-declarations]

FSEventStreamScheduleWithRunLoop(
  FSEventStreamRef   streamRef,
  CFRunLoopRef       runLoop,
  CFStringRef        runLoopMode) API_DEPRECATED("Use FSEventStreamSetDispatchQueue instead.", macos(10.5, 13.0), ios(6.0,16.0));
extern void 
FSEventStreamSetDispatchQueue(
  FSEventStreamRef              streamRef,
  dispatch_queue_t __nullable   q)                                      __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_6_0);

Sadly, I tried to modify it and it didn't work

karmops commented 1 year ago

(go version | grep -q 1.4) || go vet -all .

github.com/rjeczalik/notify

cgo-gcc-prolog:217:2: warning: 'FSEventStreamScheduleWithRunLoop' is deprecated: first deprecated in macOS 13.0 - Use FSEventStreamSetDispatchQueue instead. [-Wdeprecated-declarations] /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:1138:1: note: 'FSEventStreamScheduleWithRunLoop' has been explicitly marked deprecated here

github.com/rjeczalik/notify

./testing_test.go:740:5: call to (T).Fatalf from a non-test goroutine ./testing_test.go:745:5: call to (T).Fatalf from a non-test goroutine ./watcher_fsevents_cgo.go:99:30: possible misuse of unsafe.Pointer ./watcher_fsevents_cgo.go:104:35: possible misuse of unsafe.Pointer ./watcher_fsevents_cgo.go:106:23: possible misuse of unsafe.Pointer

josharian commented 1 year ago

It is possible to silence the warning for now with:

#cgo CFLAGS: -Wno-deprecated-declarations

But that'll obviously only work until it doesn't. :)

I'm game to try to fix the issue properly, or to send that one-line temporary patch, if it'll get reviewed. @rjeczalik?

rjeczalik commented 1 year ago

I'm game to try to fix the issue properly, or to send that one-line temporary patch, if it'll get reviewed. @rjeczalik?

@josharian You have my axe 🫡

josharian commented 1 year ago

I started on this and have a dispatch_queue_t-based implementation working, but I need to read some more docs to make sure it is actually correct, not just accidentally correct. :) Meanwhile, I sent #214 as preliminary cleanup to make all the tests pass.