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

Compilation error with Go 1.10.1 #12

Open
TheTophatDemon opened this issue Apr 22, 2018 · 2 comments
Open

Compilation error with Go 1.10.1 #12

TheTophatDemon opened this issue Apr 22, 2018 · 2 comments

Comments

@TheTophatDemon
Copy link

On attempting to build the library with 32-bit Go 1.10.1, I received a type conversion error in this function:

// Returns true if the error indicator is set on the given file, i.e. there was
// some sort of previous error.
func (f *File) HasError() bool {
	return C.al_ferror((*C.ALLEGRO_FILE)(f)) != 0
}

The error is as follows:
allegro\file.go:89: cannot convert 0 (type untyped number) to type _Ctype__Bool
allegro\file.go:89: invalid operation: (func literal)((*_Ctype_struct_ALLEGRO_FILE)(f)) != 0 (mismatched types _Ctype__Bool and int)

I was able to fix it simply by casting C.al_ferror((*C.ALLEGRO_FILE)(f)) to a bool and returning its inverse, but it should be fixed in the repository at some point.

@dradtke
Copy link
Owner

dradtke commented May 11, 2020

Can you explain more about your fix? I just tried changing that function to this:

func (f *File) HasError() bool {                                                                                                                                                                                                              
    v := bool(C.al_ferror((*C.ALLEGRO_FILE)(f)))                                                                                                                                                                                              
    return !v                                                                                                                                                                                                                                 
}

and that gives me this error:

allegro/file.go:89:11: cannot convert (func literal)() (type _Ctype_int) to type bool

This is with Go 1.14.2 on linux/amd64, but the Allegro docs indicate that this function returns an int and not a bool, so the existing version seems like it should be more correct?

@TheTophatDemon
Copy link
Author

Looking at my copy of the library's code on my computer, it seems as though it is unchanged...
I am currently having trouble updating my Go installation properly, so I'm afraid I can't really help you at the moment.

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

2 participants