Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some function with special name would not compile #356

Open
Neutron3529 opened this issue Jun 7, 2024 · 1 comment
Open

some function with special name would not compile #356

Neutron3529 opened this issue Jun 7, 2024 · 1 comment

Comments

@Neutron3529
Copy link

for example, such rust code works fine:

fn r#try(a:i32, b:i32)->i32{a+b}

but rextendr has issue exporting it.

It is nothing more than an edge case. Things might be done with a hand-writting macro.


I'm trying writting a macro about auto exporting function without explictly use the annoying macro:

extendr_module! {
    mod rext;
    fn hello_world;
}

Instead, if I success, just writting :

done!{Yes, it is done!};

is enough.

the trick should be re-define the function with the same name in a new module, for example, _please_do_not_use_rmin_export_interface_as_your_mod_name_, and use the following trick to merge all of the function in a single mod

mod private_foo {
    #[no_mangle]
    extern "C" fn foo(){} // not-so-private function
}
pub mod _please_do_not_use_rmin_export_interface_as_your_mod_name_ {
    pub extern "C" {
        fn foo();
    }
    const FOO_PTR:*const()=foo as *const_; // use pub extern fn foo::foo, which equals to the private_foo::foo thanks to the `#[no_mangle]` attribute.
}

That's all what I have found in the last week. Hope that may help develop a better rextendr:)

I might have several problem for packing R packages in the future (it cost me a day to switch the compile script to a ugly script compiles my crate), wondering is it possible to get some help here.

@Ilia-Kosenkov
Copy link
Member

Hi, thanks for reporting this. We already had this issue some time ago, I though it has been addressed. I'll check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants