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: allow calling C function pointers #3364

Closed
alberts opened this issue Mar 21, 2012 · 11 comments

Comments

@alberts
Copy link
Contributor

commented Mar 21, 2012

What steps will reproduce the problem?

Brought over from issue #2313.

I was trying to find a workaround for the inlined functions issue with gccgo:

http://stackoverflow.com/questions/1474030/how-can-i-tell-gcc-not-to-inline-a-function

I tried this the function pointer suggestion, but I got:

call of non-function C.foo_ptr

Might be nice if that could work. I think it will help when wrapping the JVM API too.

Please provide any additional information below.

small example attached. I think it's right.

Attachments:

  1. funcptr.go (132 bytes)
  2. funcptr_test.go (82 bytes)
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Mar 21, 2012

Comment 1:

Labels changed: added priority-later, cgo, removed priority-triage.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Sep 12, 2012

Comment 2:

Status changed to Accepted.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Sep 12, 2012

Comment 3:

Labels changed: added go1.1maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Sep 14, 2012

Comment 4:

Note that you can work around this by writing a C function 'call' in the header that you
use to call a particular type of function pointer + arguments combination. And then use
C.call(C.foo_ptr, args).
I agree that it would be nice if it worked as C.foo_ptr(args) though.
@robpike

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2013

Comment 5:

Labels changed: removed go1.1maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Jul 30, 2013

Comment 6:

Labels changed: added go1.3maybe.

@robpike

This comment has been minimized.

Copy link
Contributor

commented Aug 20, 2013

Comment 7:

Labels changed: removed go1.3maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Nov 27, 2013

Comment 8:

Labels changed: added go1.3maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Dec 4, 2013

Comment 9:

Labels changed: added release-none, removed go1.3maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Dec 4, 2013

Comment 10:

Labels changed: added repo-main.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Mar 26, 2014

Comment 11:

I believe this is as fixed as it ever will be.  See misc/cgo/test/fpvar.go.

Status changed to Fixed.

@alberts alberts added fixed labels Mar 26, 2014

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

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