| Crates.io | cdefines |
| lib.rs | cdefines |
| version | 0.1.4 |
| created_at | 2019-05-12 08:57:09.8411+00 |
| updated_at | 2022-06-05 01:39:29.896585+00 |
| description | A proc macro that translates c #define constants to rust consts |
| homepage | https://github.com/jiegec/cdefines |
| repository | https://github.com/jiegec/cdefines |
| max_upload_size | |
| id | 133699 |
| size | 10,138 |
Turn #define C codes into Rust constants.
Add to code:
extern crate cdefines;
#[cdefines::preprocessor]
const IOCTL: &str =
"#define TCGETS 0x5401
#define TCSETS 0x5402
#define TCSETSW 0x5403
#define TCSETSF 0x5404";
It gets translated to:
const IOCTL_TCGETS: usize = 0x5401;
// ...
enum IOCTL {
TCGETS = 0x5401,
// ...
}
#define A 0x1234.#define A 123 and then #define B A.