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 call functions with variable-argument lists. #975

Open
gopherbot opened this Issue Jul 29, 2010 · 8 comments

Comments

Projects
None yet
5 participants
@gopherbot

gopherbot commented Jul 29, 2010

by akidan:

A package such as the following will not compile with cgo. 
(printf is a contrived example, but this would be useful for bridging objective c
through id objc_msgSend(id self, SEL op, ...);)

--- (file foo.go)
package foo

// #include <stdio.h>
import "C"

func PrintStuff() {
    C.printf(C.CString("Hello"))
}

---

$ cgo foo.go

What is the expected output?
Program compiles and is able to call function with variable-argument list.

What do you see instead?
unexpected type: ...

What is your $GOOS?  $GOARCH?
darwin amd64

Which revision are you using?  (hg identify)
43fd9bb529f0+ tip
@rsc

This comment has been minimized.

Contributor

rsc commented Jul 29, 2010

Comment 1:

I'm not sure this will ever work.  It's very hard to type check and do correctly.

Labels changed: added priority-low, removed priority-medium.

Owner changed to r...@golang.org.

Status changed to LongTerm.

@gopherbot

This comment has been minimized.

gopherbot commented Jul 30, 2010

Comment 2 by akidan:

Thank you for the update all the same - transparency is appreciated!
@rsc

This comment has been minimized.

Contributor

rsc commented Dec 9, 2011

Comment 3:

Labels changed: added priority-someday.

@rsc

This comment has been minimized.

Contributor

rsc commented Dec 4, 2013

Comment 5:

Labels changed: added repo-main.

@rsc

This comment has been minimized.

Contributor

rsc commented Mar 3, 2014

Comment 6:

Adding Release=None to all Priority=Someday bugs.

Labels changed: added release-none.

@LionNatsu

This comment has been minimized.

Contributor

LionNatsu commented Jan 24, 2018

I think this should be documented as it is a long-term issue.

While wiki says:

... That is, if you want to call the C function printf() from Go code, you write C.printf(). Since variable argument methods like printf aren't supported yet (issue 975), we will wrap it in the C method "myprint":...

The documentation of cgo should be more explicit for the issue, but now it not even mention this.

@bradfitz

This comment has been minimized.

Member

bradfitz commented Jan 24, 2018

@LionNatsu, please file a new bug just for documenting that. It's true that I see nothing at https://golang.org/cmd/cgo/ about variadic args.

@gopherbot

This comment has been minimized.

gopherbot commented Jan 28, 2018

Change https://golang.org/cl/90415 mentions this issue: cgo: Update documentation on calling C variadic functions

gopherbot pushed a commit that referenced this issue Jun 13, 2018

cgo: update documentation on calling C variadic functions
The current implementation does not support calling C variadic
functions (as discussed in #975). Document that.

Fixes #23537

Change-Id: If4c684a3d135f3c2782a720374dc4c07ea66dcbb
Reviewed-on: https://go-review.googlesource.com/90415
Reviewed-by: Ian Lance Taylor <iant@golang.org>

dna2github added a commit to dna2fork/go that referenced this issue Jun 14, 2018

cgo: update documentation on calling C variadic functions
The current implementation does not support calling C variadic
functions (as discussed in golang#975). Document that.

Fixes golang#23537

Change-Id: If4c684a3d135f3c2782a720374dc4c07ea66dcbb
Reviewed-on: https://go-review.googlesource.com/90415
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment