I'm trying to create the possibility to parse C header file at compile-time (and generate a bunch of numeric constants to be used in other code). I don't need to get all the header file constructs parsed, since I control its contents and know that this file will have only #define
s in it. So I tried the following:
macro_rules! parse_defines {
($(#define $x:ident $v:expr)+) => {$(
const $x: isize = $v;
)+};
}
It works when I write #define
s in the code itself, but not when I use include!
, since the include!
macro isn't expanded before my macro is, and it fails with "no rules expected the token" error. Is there any workaround for this, or do I have to go for the proc macro?