-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Random drive-by thought: if external_library generated code like this when not having the dlopen feature:
mod private {
#[link(name = "foo")]
extern "C" {
static me: c_int;
static you: c_float;
fn foo() -> c_int;
fn bar(_: c_int, _: c_float) -> ();
fn baz(_: *const c_int) -> c_int;
fn blah(_: c_int, _: c_int, ...) -> *const c_void;
fn bleh(_: c_int, ...) -> ();
}
pub struct Foo {
pub me: &'static c_int,
pub you: &'static c_float,
pub foo: unsafe extern "C" fn() -> c_int,
pub bar: unsafe extern "C" fn(c_int, c_float) -> (),
pub baz: unsafe extern "C" fn(*const c_int) -> c_int,
pub blah: unsafe extern "C" fn(c_int, c_int, ...) -> *const c_void,
pub bleh: unsafe extern "C" fn(c_int, ...) -> (),
}
impl Foo {
pub fn open(_: Option<&str>) -> Result<Foo, DlError> { /* ... */ }
}
}
use private::Foo;Then the user could just always use Foo::open(find_solib_or_none("foo.so")).foo(), without having to care about the dlopen feature?
It'd probably also reduce a bit the issue with the dlopen feature, which is that currently it's not additive.
That said it would still not really be, but if Foo::open(None) with the dlopen feature searched in the so path… then maybe it'd actually become kind of additive? (still not perfectly so, but at least for all reasonable users that either pass a valid Some(lib) or None it'd be)
Metadata
Metadata
Assignees
Labels
No labels