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

cmd/cgo: cannot wrap mpfr_get_prec from libmpfr #17537

Closed
rsc opened this issue Oct 21, 2016 · 2 comments

Comments

@rsc
Copy link
Contributor

commented Oct 21, 2016

From #15386:

```go
package foo

/*
#cgo LDFLAGS: -lmpfr -lgmp
#include <gmp.h>
#include <mpfr.h>
*/
import "C"

func Bar() {
    _ = 1
    _ = 2
    _ = 3
    _ = 4
    _ = 5
    _ = 6
    _ = 7
    _ = 8
}

func Prec() C.mpfr_prec_t {
    return C.mpfr_get_prec(nil)
}

func Foo3() {
    _ = 1
    _ = 2
    _ = 3
}

func Foo2() {
    _ = 4
    _ = 5
    _ = 6
}

func Foo() {
    _ = 1
    _ = 2
    _ = 3
    _ = 4
    _ = 5
    _ = 6
    _ = 7
    _ = 8
    _ = 9
    _ = 10
    _ = 11
    // this isn't the line you're looking for
}
```

```
# command-line-arguments
In file included from ./test.go:6:0:
./test.go: In function ‘_cgo_b5bec8c53dc8_Cfunc_mpfr_get_prec’:
./test.go:49:6: error: request for member ‘_mpfr_prec’ in something not a structure or union
  // this isn't the line you're looking for
      ^
./test.go:49:6: error: request for member ‘_mpfr_prec’ in something not a structure or union
  // this isn't the line you're looking for
      ^
```

Ignore the commentary about line numbers being wrong. The real problem for this issue is that the generated wrapper doesn't compile.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Nov 10, 2016

This is caused by the (void*) cast introduced by https://golang.org/cl/5786047, which presciently says "Eventually that will produce other warnings." In this case the call is actually a preprocessor macro, and the cast causes the macro to fail.

Looking for a fix.

@ianlancetaylor ianlancetaylor self-assigned this Nov 10, 2016

@gopherbot

This comment has been minimized.

Copy link

commented Nov 10, 2016

CL https://golang.org/cl/33097 mentions this issue.

@gopherbot gopherbot closed this in fb8c896 Nov 11, 2016

@golang golang locked and limited conversation to collaborators Nov 11, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants
You can’t perform that action at this time.