Thanks, Ian and Andrey.
On Thu, 2019-12-05 at 21:06 -0800, Ian Lance Taylor wrote:
> On Thu, Dec 5, 2019 at 9:02 PM andrey mirtchovski <
> mirtchov...@gmail.com> wrote:
> >
> > i think cgo does some magic with defining functions called via
> > C.funcname. if you have the same func defined in the
On Thu, Dec 5, 2019 at 9:02 PM andrey mirtchovski wrote:
>
> i think cgo does some magic with defining functions called via
> C.funcname. if you have the same func defined in the C preamble as
> well as call it from the same Go file you get the same func defined
> twice. putting it elsewhere as
i think cgo does some magic with defining functions called via
C.funcname. if you have the same func defined in the C preamble as
well as call it from the same Go file you get the same func defined
twice. putting it elsewhere as an extern seems to work.
to be honest i never dug into it. i did it
Thanks. Can you explain the reason for this so it sticks in my head?
On Thu, 2019-12-05 at 21:03 -0700, andrey mirtchovski wrote:
> you just need to split it in two files. the cfuncs go into another
> (sorry for lack of playground link):
>
> $ go build cgo.go cfunc.go
> $ ./cgo
> Hello from
you just need to split it in two files. the cfuncs go into another
(sorry for lack of playground link):
$ go build cgo.go cfunc.go
$ ./cgo
Hello from stdio
$ cat cgo.go
package main
/*
#include
extern void myprint(char *s);
*/
import "C"
import "unsafe"
//export Example
func Example() {
cs
I am trying to write a shared module that will be called from C, but I
have run into a problem in using the work-around in
https://github.com/golang/go/wiki/cgo#the-basics for calling variadic C
functions.
The case that I have is more complex, but altering the example at the
wiki demonstrates