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)]

#[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:


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!