Importing C macro constants: Proof of concept

Hi, I’ve written a rustc plugin that imports C macro constants from C headers directly from the source code.

Example usage:

#![feature(plugin, custom_attribute)]
#![plugin(c_import)]


#[c_import(h = "limits.h", INT_MAX)]
mod limits
{
    // This module is empty now, but the plugin will import
    // requested constants in here at compile time.
}

fn main()
{
    println!("Yay, got INT_MAX: {}", limits::INT_MAX);
}

Details in blog:

http://vojtech.kral.hk/en/rust-importing-c-constants-proof-of-concept/

2 Likes

If there are Windows users out there wlling to test this I’d be delighted to hear whether it works there :smile:

This looks cool!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.