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
Closed

cmd/cgo: cannot wrap mpfr_get_prec from libmpfr #17537

rsc opened this issue Oct 21, 2016 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@rsc
Copy link
Contributor

rsc 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.

@rsc rsc added this to the Go1.8 milestone Oct 21, 2016
@quentinmit quentinmit added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 21, 2016
@ianlancetaylor
Copy link
Contributor

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
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants