macdriver icon indicating copy to clipboard operation
macdriver copied to clipboard

error: returning 'id' from a function with incompatible result type 'double'

Open iMacker2020 opened this issue 3 years ago • 6 comments

I tried to run all the examples in the example folder, but saw these errors every time:

cocoa/cocoa_objc.gen.go:3043:9: error: returning 'id' from a function with incompatible result type 'double'
        return [(NSScreen*)id
               ^~~~~~~~~~~~~~
cocoa/cocoa_objc.gen.go:3053:9: error: returning 'id' from a function with incompatible result type 'double'
        return [(NSScreen*)id

How to reproduce: cd to root level of the macdriver folder. Build the OpenGL example like this: go build ./examples/opengl/main.go

My info: Mac OS 10.14 Go 1.18

Notes: I used the June 11th version of MacDriver. I downloaded a zip file from GitHub.com.

iMacker2020 avatar Jul 11 '22 19:07 iMacker2020

I found out that the problem functions were defined in Mac OS 10.15, so Mac OS 10.14 wouldn't have them.

I have a few suggestions on how to solve this problem:

  • define officially supported versions of Mac OS or AppKit.
  • add conditional code that disables functions that are found on newer versions of AppKit than what the current computer has.
  • make some kind of program that can automatically create the bindings for AppKit and keep a separate version of each version of Mac OS.

iMacker2020 avatar Jul 11 '22 20:07 iMacker2020

Awesome find! Yea I think since we generate bindings, we should generate for different versions. I don't have any help with this project though. For now we can just say we support a minimum version somewhere.

progrium avatar Jul 11 '22 21:07 progrium

I did like the idea of using documentation to generate code. I picture a program that scans thru Apple's official documentation and reads all the functions, constants, and types. Then translates them to Go code. A simple condition could read which version of Mac OS the current symbol is defined in and decide whether to use it or not.

For now what is the minimum version of Mac OS going to be?

iMacker2020 avatar Jul 11 '22 21:07 iMacker2020

Yeah, that's the idea.

Regarding min version, whatever works. 10.5 until proven otherwise?

progrium avatar Jul 11 '22 22:07 progrium

The 1.16 Release Notes state that that is the last version to support 10.12.

TotallyGamerJet avatar Jul 21 '22 11:07 TotallyGamerJet

That is the "official" supported version. But I do have plans on porting Go to PowerPC and older versions of Mac OS.

iMacker2020 avatar Jul 21 '22 11:07 iMacker2020

Wow. Well you can always use the dynamic API and skip the bindings (just use objc package and Send method). Sounds like a special case. It will be hard enough supporting the supported versions.

progrium avatar Jul 24 '23 17:07 progrium