Hi,

Idea:

  #[prefix="http_parser_"]
  extern {
    pub fn init(parser: *http_parser, _type: enum_http_parser_type);
    …
  }

This have a few niceties:

* You don't have repeat the prefix in every function
* You can now write http_parser::init(…) to call the function

However, let's also introduce another concept:

  #[autoprefix]
  extern {
    pub fn init(parser: *http_parser, _type: enum_http_parser_type);
    …
  }

The autoprefix every function with the crate-name and crate-SHA1. You
can then compile your C library with -DPREFIX=`rustc
--crate-autoprefix`.

--

So, the reason I want this is to integrate with C libraries that I
control (i.e. they are bundled with the Rust package) and at the same
time support Rust models of allowing multiple versions of the same
crate in the same binary. In this particular crate I'm using a
slightly modified http_parser, and I'd rather not "leak" the symbols
into the

This is basically a poor-man's namespace functionality for C libraries.

Even if you don't completely control the C library (e.g. you're just
bundling http_parser as-is) you can use objcopy or other tools to
autoprefix after you've compiled it into an object file.

Thoughts?

I've already tried to accomplish the same with linker flags, but I
haven't found a cross-platform way of hiding specific symbols in a
safe way.

// Magnus Holm
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to