ebitengine / purego

Apache License 2.0
1.95k stars 63 forks source link

change how bool return values are converted #181

Closed JupiterRider closed 7 months ago

JupiterRider commented 7 months ago

Sometimes C functions don't return 0 when false, but instead this conversion works.

JupiterRider commented 7 months ago

@TotallyGamerJet What do you think?

TotallyGamerJet commented 7 months ago

It what case does the original not work? Isn't the go implementation of bools just a byte where 0 is false and other values true?

JupiterRider commented 7 months ago

I am working on a purego version of raylib. I figured out, that some functions didn't work. They always returned true.

Here is an example:

var isFileDropped func() uintptr
purego.RegisterLibFunc(&isFileDropped, raylib, "IsFileDropped")

fmt.Println(isFileDropped()) returns 140021448219136

https://github.com/raysan5/raylib/blob/master/src/rcore.c#L2205

I don't know, why this behavior affects only some functions.

TotallyGamerJet commented 7 months ago

Please make an issue and then answer these questions: Well that number is indeed not zero. Do u expect it to return false? what number does the C version return? What other functions always return true?