Skip to content

failed use statements? #5430

Closed
Closed

Description

Trying out some FFI

➜ rustc version.rs
versions.rs:7:29: 7:35 error: use of undeclared type name `c_char`
versions.rs:7     fn version_string () -> *c_char;
                                           ^~~~~~
versions.rs:8:39: 8:45 error: use of undeclared type name `c_uint`
versions.rs:8     fn version_interface_current () -> c_uint;
                                                     ^~~~~~
versions.rs:9:40: 9:46 error: use of undeclared type name `c_uint`
versions.rs:9     fn version_interface_revision () -> c_uint;
                                                      ^~~~~~
versions.rs:10:35: 10:41 error: use of undeclared type name `c_uint`
versions.rs:10     fn version_interface_age () -> c_uint;
                                                  ^~~~~~
error: aborting due to 4 previous errors
➜  re2  cat versions.rs
use core::libc::{c_char, c_uint};

mod re2 {
  #[link_name = "cre2"]
  #[link_args = "-lcre2"]
  extern {
    fn version_string () -> *c_char;
    fn version_interface_current () -> c_uint;
    fn version_interface_revision () -> c_uint;
    fn version_interface_age () -> c_uint;
  }
}

fn version_interface_age () -> c_uint {
  unsafe {
    re2::version_interface_age()
  }
}

fn main () {
  io::println(fmt!("%?", version_interface_age));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions