Giter Site home page Giter Site logo

Comments (6)

fatemender avatar fatemender commented on September 18, 2024 1

No reason, I just didn't have enough time to tweak the generated bindings. I would be happy to accept a PR for that! Otherwise, I think I might get back to that issue someday but not sure when.

from boolector-sys.

fatemender avatar fatemender commented on September 18, 2024

Hi,

it is not possible (or at least portable) to use std::fs::File and *mut FILE interchangeably, see this thread on Reddit. However you should be able to cast between *mut boolector_sys::FILE and *mut libc::FILE and use the libc crate functions. I currently can't check this, though, will try to make a working example in a few hours.

Hope that helps.

from boolector-sys.

cdisselkoen avatar cdisselkoen commented on September 18, 2024

Great, that does help! I'll look at casting to libc::FILE. Thanks for the quick response!

from boolector-sys.

fatemender avatar fatemender commented on September 18, 2024

Just in case, here is a quick-and-dirty example.

use std::ffi::CString;
use std::ptr;

use boolector_sys as bs;
use libc;

fn main() {
    unsafe {
        let btor = bs::boolector_new();
        bs::boolector_set_opt(btor, bs::BtorOption_BTOR_OPT_MODEL_GEN, 1);
        let b8 = bs::boolector_bitvec_sort(btor, 8);
        let x = bs::boolector_var(btor, b8, ptr::null());
        let y = bs::boolector_var(btor, b8, ptr::null());
        let s56 = CString::new("56").unwrap();
        let c56 = bs::boolector_constd(btor, b8, s56.as_ptr());
        let mul = bs::boolector_mul(btor, x, y);
        let equ = bs::boolector_eq(btor, mul, c56);
        let filename = CString::new("output.txt").unwrap();
        let mode = CString::new("w").unwrap();
        let outfile = libc::fopen(filename.as_ptr(), mode.as_ptr());
        bs::boolector_assert(btor, equ);
        bs::boolector_dump_smt2(btor, outfile as _);
        assert_eq!(bs::boolector_sat(btor), bs::BtorSolverResult_BTOR_RESULT_SAT as _);
        let smt2 = CString::new("smt2").unwrap();
        bs::boolector_print_model(btor, smt2.as_ptr() as _, outfile as _);
        libc::fclose(outfile);
        bs::boolector_delete(btor);
    }
}

from boolector-sys.

cdisselkoen avatar cdisselkoen commented on September 18, 2024

Great, thanks!

from boolector-sys.

cdisselkoen avatar cdisselkoen commented on September 18, 2024

Actually, just curious - is there a reason that boolector-sys couldn't just use the libc::FILE type directly? Is there a benefit to having its own FILE type?

from boolector-sys.

Related Issues (4)

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.