You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
./params.go:28:9: expected selector or type assertion, found 'func'
Look, I understand that this is a parsing error. I also understand that Go's goal is to have a one-pass parser. Having to check if we're in a C.XXX context will make it two passes. I have no suggestions.
Workaround
Right now I have a terrible workaround: the struct creation is a cgo function that I call, passing in all the correct values. This is not ideal clearly. The whole point of using CUDA is to speed up computation, and if I have to call cgo repeatedly then that's not great. Especially in this case, where the compiler's just allocating a data structure and populating with values.
The text was updated successfully, but these errors were encountered:
Go references to C
Within the Go file, C's struct field names that are keywords in Go can be
accessed by prefixing them with an underscore: if x points at a C struct
with a field named "type", x._type accesses the field.
So in this case the field can be referred to as _func, not func.
There is no need to "look into the whole func-as-a-keyword thing".
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Will try later when I have access to a machine with
gvm
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I am adding CUDA 11 support for the CUDA library. This means using cgo. One of the structs is defined as follows:
This struct needs to be passed into a function call.
I am unable to set the field
.func
. I have tried with a literal:I have tried it as a selector:
What did you expect to see?
No parsing errors
What did you see instead?
For the first case I got:
For the second case I got:
Look, I understand that this is a parsing error. I also understand that Go's goal is to have a one-pass parser. Having to check if we're in a
C.XXX
context will make it two passes. I have no suggestions.Workaround
Right now I have a terrible workaround: the struct creation is a cgo function that I call, passing in all the correct values. This is not ideal clearly. The whole point of using CUDA is to speed up computation, and if I have to call cgo repeatedly then that's not great. Especially in this case, where the compiler's just allocating a data structure and populating with values.
The text was updated successfully, but these errors were encountered: