go-allegro
go-allegro copied to clipboard
Compilation error with Go 1.10.1
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.
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?
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.