PureGo Version
v0.10.2, and main as of today
Operating System
Go Version (go version)
go1.26.5 linux/amd64
What steps will reproduce the problem?
Declare a C function that returns a function pointer, so the Go side has a func return type:
var fn func() func(a, b int32) int32
purego.RegisterLibFunc(&fn, lib, "return_func_ptr")
add := fn()
Registering it is fine, its the call that goes, and it goes for every signature I tried.
What is the expected result?
fn() hands back a callable func(int32, int32) int32.
What happens instead?
panic: reflect.MakeFunc: value of type *func(int32, int32) int32 is not assignable to type func(int32, int32) int32
Anything else you feel useful to add?
The RegisterFunc type table has func <=> C function in it, but that only seems to hold in the argument direction. Every other case in that return switch leaves the result as the declared type - the reflect.Func case swaps in a *func, registers into that, and hands the pointer back to MakeFunc, which wont take it.
Been that way since #49 in 2022 as far as I can tell. Fix and a test are in #500.
PureGo Version
v0.10.2, and main as of today
Operating System
Go Version (
go version)go1.26.5 linux/amd64
What steps will reproduce the problem?
Declare a C function that returns a function pointer, so the Go side has a func return type:
Registering it is fine, its the call that goes, and it goes for every signature I tried.
What is the expected result?
fn()hands back a callablefunc(int32, int32) int32.What happens instead?
Anything else you feel useful to add?
The
RegisterFunctype table hasfunc <=> C functionin it, but that only seems to hold in the argument direction. Every other case in that return switch leaves the result as the declared type - thereflect.Funccase swaps in a*func, registers into that, and hands the pointer back toMakeFunc, which wont take it.Been that way since #49 in 2022 as far as I can tell. Fix and a test are in #500.