Skip to content
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

fp_st type is incompatible with cgo FFI #60

Open
FiloSottile opened this issue Jan 5, 2018 · 1 comment
Open

fp_st type is incompatible with cgo FFI #60

FiloSottile opened this issue Jan 5, 2018 · 1 comment
Milestone

Comments

@FiloSottile
Copy link

cggo can't see through "fp_st and fp_t are both different fancy typedefs for dig_t*", and gets particularly confused by the array type.

relic/relic.go:189: cannot use ep.st.y (type C.fp_st) as type *C.dig_t in argument to _Cfunc__fp_neg
relic/relic.go:189: cannot use ep.st.y (type C.fp_st) as type C.fp_t in argument to _Cfunc__fp_neg
@conradoplg
Copy link
Contributor

Yep, turns out RELIC really isn't wrapper-friendly 😬

A proper solution will have to wait for the refactoring that @dfaranha is planning. But in the meantime, I was able to run this unholy mess:

package main

// #cgo CFLAGS: -I/home/conrado/workspace/relic/build/include  -I/home/conrado/workspace/relic/include
// #cgo LDFLAGS: -lrelic -L/home/conrado/workspace/relic/build/lib/
// #include <relic.h>
import "C"
import "fmt"

func main() {
	C.core_init()
	C.fp_param_set_any()
	x := make([]C.dig_t, 4)
	px := &x[0]

	x[0] = 1
	fmt.Println(x)
	C.fp_neg_basic(px, px)
	fmt.Println(x)

	var p C.ep_t
	p[0].x[0] = 1
	fmt.Println(p[0].x)
	px = &p[0].x[0]
	C.fp_neg_basic(px, px)
	fmt.Println(p[0].x)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants