[go-nuts] Generics: Is this not supported ?

2022-10-25 Thread Elemer Pixard
I am trying to create a generic function which returns a Container with a slice of the specified type T: https://go.dev/play/p/GS_x9Y8HOMK Is this not supported or am I doing something wrong ? Regards. -- You received this message because you are subscribed to the Google Groups "golang-nuts" gr

Re: [go-nuts] How to force cgo to use C++ compiler (g++) instead of gcc ?

2021-11-02 Thread Elemer Pixard
-- So the user build the library for different backends: >go install -tags backend1 or >go install -tags backend2 On Monday, November 1, 2021 at 5:13:14 PM UTC-3 Ian Lance Taylor wrote: > On Sun, Oct 31, 2021 at 10:17 AM Elemer Pixard wrote: > > > > I am developing a

[go-nuts] How to force cgo to use C++ compiler (g++) instead of gcc ?

2021-10-31 Thread Elemer Pixard
I am developing a binding to a C++ library using a wrapper module (using extern "C" directive). The C++ library files are in a subdirectory of the package. If I create a file in the package directory such as: lib.cpp -- #include "cpplib/file.cpp" #include "cpplib/wrapper.cpp"

Re: [go-nuts] initialization loop ?

2021-10-22 Thread Elemer Pixard
This should be possible, because the slice simply contains the address of the function. Why the compiler cares what the function will be doing when called ? Equivalent code will work in several other languages. On Friday, October 22, 2021 at 2:59:36 PM UTC-3 Jan Mercl wrote: > testSlice mentions

[go-nuts] Re: cgo question

2021-09-25 Thread Elemer Pixard
Using unsafe.Pointer instead of the C type: C.device_t solved the problem: func Open() { var dev unsafe.Pointer C.open(&dev) } On Saturday, September 25, 2021 at 12:13:04 PM UTC-3 Elemer Pixard wrote: > Correction: The Go function is: > func Open() { > var dev *C.device

[go-nuts] Re: cgo question

2021-09-25 Thread Elemer Pixard
Correction: The Go function is: func Open() { var dev *C.device_t C.open(&dev) } On Saturday, September 25, 2021 at 10:59:45 AM UTC-3 Elemer Pixard wrote: > I am trying to call the following C function (simplified version from a C > library) from Go, > and I got compiler erro

[go-nuts] cgo question

2021-09-25 Thread Elemer Pixard
I am trying to call the following C function (simplified version from a C library) from Go, and I got compiler errors: typedef void device_t; void open(device_t **dev) { } *Go Function*: func Open() { var dev C.device_t C.open(&&dev) } *Compiler (v1.17) error:* cannot use _cgo0 (type **_Ct

[go-nuts] Is it possible to cache Javascript function references and then Invoke() them ? (WebAssembly)

2019-03-08 Thread Elemer Pixard
Hi, The recommended way to call a Javascript function through syscall/js seems to be: doc := js.Global().Get("document") div := doc.Call("createElement", "div") Why is not possible to cache the Javascript function reference like this: doc := js.Global().Get("document") createElement := doc.G