Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot use _Cfunc_objc_getClass(cclass) (type C.Class) as type C.id #5

Closed
shenyp09 opened this issue May 12, 2014 · 7 comments
Closed

Comments

@shenyp09
Copy link

Build failure on OSX 10.9.2

github.com/andlabs/ui

Documents/Go/src/github.com/andlabs/ui/objc_darwin.go:21: cannot use _Cfunc_objc_getClass(cclass) (type C.Class) as type C.id in return argument

@andlabs
Copy link
Owner

andlabs commented May 12, 2014

A local change I just made (implementing the handled return of AreaHandler.Mouse()) breaks darwin/386 and at this point I'm mostly convinced writing portable code with the Objective-C runtime directly is impossible. I'm going to investigate the possibility of switching to using Objective-C directly and do that today; this may require having to rewrite the types in Objective-C directly. I'm not sure how this will affect the other use of objc_getClass() (to get classes for making instances).

In the meantime, you can fix your immediate problem locally with

diff --git a/objc_darwin.go b/objc_darwin.go
index c1b610d..d1fae75 100644
--- a/objc_darwin.go
+++ b/objc_darwin.go
@@ -18,7 +18,7 @@ func objc_getClass(class string) C.id {
    cclass := C.CString(class)
    defer C.free(unsafe.Pointer(cclass))

-   return C.objc_getClass(cclass)
+   return C.id(C.objc_getClass(cclass))
 }

 func sel_getUid(sel string) C.SEL {

@nf
Copy link

nf commented May 15, 2014

That change doesn't fix the build for me (10.9.2 also). I get

./objc_darwin.go:21: cannot convert _Cfunc_objc_getClass(cclass) (type C.Class) to type C.id

@shenyp09
Copy link
Author

Yes. I have tried to convert C.Class to C.id and get the same result with nf. Clearly it's unable to change C.Class to to C.id directly(Maybe just cannot do that convert just under OSX 10.9.2).

@andlabs
Copy link
Owner

andlabs commented May 15, 2014

I see, hm... I'm in the process of doing the Objective-C conversion; hopefully by tonight or tomorrow I'll have pushed everything and we can try again. This conversion will get rid of that C.objc_getClass() call (or anything working with Class directly).

@andlabs
Copy link
Owner

andlabs commented May 16, 2014

Conversion finished. Does it work now?

@shenyp09
Copy link
Author

Great! It works now. BTW, there is still a warning when building the package, but it seems not a serious problem.

github.com/andlabs/ui

Documents/Go/src/github.com/andlabs/ui/objc_darwin.m:23:9: warning: returning 'const char *' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]

@andlabs
Copy link
Owner

andlabs commented May 16, 2014

Right; I'll take care of that soon, as well as any other warnings that may come up when -Wall -Wextra are added. Thanks!

@andlabs andlabs closed this as completed May 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants