-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
sdl.PushEvent(&sdl.UserEvent)
produces "Cgo argument has Go pointer to Go pointer" for non-nil Data1
or Data2
#534
Comments
Hi @iBug, thanks for submitting the question! I believe due to Go's garbage collector default behavior of disallowing having Go pointer within the object another Go pointer is pointing to, it is not possible to pass data to SDL2 which is using C runtime using Go-allocated pointers. However if you would like to experiment with passing Go-allocated pointer to SDL2, you can disable the check by disabling the check using the command Another, more long-winded way which satisfies Go's default behavior is that you can allocate data using C and pass C-allocated pointer instead like the following example:
Since I allocated using C, I also needed to free using C at some point. In this case, I chose to free immediately after processing it. |
Thank you for your response. I'm not familiar with Cgo so I'd rather not touch that part with my application. I ended up |
Oh that's really smart! I'm glad that you found a better solution. |
This was originally asked on Stack Overflow, but I later discovered that
Data1
andData2
are completely unusable.The code snippet is:
In fact,
Data1
can't be anything non-nil, so even this gives the "Go pointer to Go pointer" error:Am I missing something? What is the correct way to pass extra data using
Data1
andData2
pointers?The text was updated successfully, but these errors were encountered: