Coder Social home page Coder Social logo

ffi's People

Contributors

sbinet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

kitech isgasho

ffi's Issues

Error calling Rust Function from Go

Hi.
Not sure how this library supporting, but I'm getting troubles calling Rust function from Go.

Here simple Rust function:
use std::thread;

#[no_mangle]
pub extern fn process() {
    let handles:Vec<_> = (0..10).map(|_|{
        thread::spawn(||{
            let mut x = 0;
            for _ in 0..5_000_000 {
                x += 1
            }
            x
        })
    }).collect();

    for h in handles {
        println!("Thread finished with count={}",
                 h.join().map_err(|_| "Could not join thread!").unwrap());
    }
    println!("done!");
}

And I'm calling it as described in an example:

package main

import (
	"fmt"
	"github.com/gonuts/ffi"
)

func main() {

	// dl-open a library: here, the math library on darwin
	lib, err := ffi.NewLibrary("libembed.rlib")


	// get a handle to 'cos', with the correct signature
	cos, err := lib.Fct("process", ffi.C_void, []ffi.Type{})
	handle_err(err)

	// call it
	out := cos(0.).Float()
	println("cos(0.)=", out)

	err = lib.Close()
	handle_err(err)
}

func handle_err(err error)  {
	if err != nil {
		fmt.Println("Error:",err)
	}
}

And getting the following error calling go build.

Screen Shot 2020-04-06 at 11 31 58 PM

Incompatible with Go 1.14?

This library does not build with Go 1.14 on macOS:

$ go version
go version go1.14.2 darwin/amd64

$ go get github.com/gonuts/ffi
# github.com/gonuts/ffi
$GOPATH/src/github.com/gonuts/ffi/ffi.go:190:7: cannot take the address of _Cmacro_ffi_type_uint()
$GOPATH/src/github.com/gonuts/ffi/ffi.go:192:7: cannot take the address of _Cmacro_ffi_type_sint()
$GOPATH/src/github.com/gonuts/ffi/type.go:244:50: cannot take the address of _Cmacro_ffi_type_uchar()
$GOPATH/src/github.com/gonuts/ffi/type.go:245:41: cannot take the address of _Cmacro_ffi_type_schar()
$GOPATH/src/github.com/gonuts/ffi/type.go:246:51: cannot take the address of _Cmacro_ffi_type_ushort()
$GOPATH/src/github.com/gonuts/ffi/type.go:247:42: cannot take the address of _Cmacro_ffi_type_sshort()
$GOPATH/src/github.com/gonuts/ffi/type.go:248:49: cannot take the address of _Cmacro_ffi_type_uint()
$GOPATH/src/github.com/gonuts/ffi/type.go:249:40: cannot take the address of _Cmacro_ffi_type_sint()
$GOPATH/src/github.com/gonuts/ffi/type.go:250:50: cannot take the address of _Cmacro_ffi_type_ulong()
$GOPATH/src/github.com/gonuts/ffi/type.go:251:41: cannot take the address of _Cmacro_ffi_type_slong()
$GOPATH/src/github.com/gonuts/ffi/ffi.go:192:7: too many errors

The same build errors were previously reported in #1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.