On 07/11/2012 04:33 PM, Harrison, John wrote:
Is it currently possible to call a var arg function, say printf, from
rust? Or is there a recommended work around at the moment for doing so?

It is not possible in general, though declaring and using varargs functions without the vararg argument works (it's just not very useful).

The workaround I use is to define a little file called glue.c to wrap the varargs call, then statically link it to the crate.

Statically linking just works, more or less, so if I have glue.a and my Rust code, project.rs contains:

    extern mod glue {
        my_printf(f: *c_str, i: int);
    }

Then calling `rustc -L . project.rs` should work.

-Brian
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to