Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to fit macro consts into smaller types
Add a `--fit-macro-constant-types` option to make bindgen try to fit macro integer constants into types smaller than u32/i32. Useful especially when dealing with 8/16-bit architectures. Closes #1945
- Loading branch information
Showing
9 changed files
with
176 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#![allow( | ||
dead_code, | ||
non_snake_case, | ||
non_camel_case_types, | ||
non_upper_case_globals | ||
)] | ||
|
||
pub const N0: u8 = 0; | ||
pub const N1: u8 = 1; | ||
pub const N2: u8 = 2; | ||
pub const N_1: i8 = -1; | ||
pub const N_2: i8 = -2; | ||
pub const MAX_U16: u16 = 65535; | ||
pub const MAX_I16: u16 = 32767; | ||
pub const MAX_I16_Plus1: u16 = 32768; | ||
pub const MAX_U16_Plus1: u32 = 65536; | ||
pub const MAX_I16_Minus1: u16 = 32766; | ||
pub const MAX_U16_Minus1: u16 = 65534; | ||
pub const MIN_U16: u8 = 0; | ||
pub const MIN_I16: i16 = -32768; | ||
pub const MIN_U16_Plus1: u8 = 1; | ||
pub const MIN_I16_Plus1: i16 = -32767; | ||
pub const MIN_U16_Minus1: i8 = -1; | ||
pub const MIN_I16_Minus1: i32 = -32769; | ||
pub const MAX_U32: u32 = 4294967295; | ||
pub const MAX_I32: u32 = 2147483647; | ||
pub const MAX_I32_Plus1: u32 = 2147483648; | ||
pub const MAX_U32_Plus1: u64 = 4294967296; | ||
pub const MAX_I32_Minus1: u32 = 2147483646; | ||
pub const MAX_U32_Minus1: u32 = 4294967294; | ||
pub const MIN_U32: u8 = 0; | ||
pub const MIN_I32: i32 = -2147483648; | ||
pub const MIN_U32_Plus1: u8 = 1; | ||
pub const MIN_I32_Plus1: i32 = -2147483647; | ||
pub const MIN_U32_Minus1: i8 = -1; | ||
pub const MIN_I32_Minus1: i64 = -2147483649; | ||
pub const LONG12: u64 = 123456789012; | ||
pub const LONG_12: i64 = -123456789012; | ||
extern "C" { | ||
pub fn foo( | ||
arg1: ::std::os::raw::c_int, | ||
arg2: ::std::os::raw::c_int, | ||
arg3: ::std::os::raw::c_uint, | ||
arg4: ::std::os::raw::c_char, | ||
arg5: ::std::os::raw::c_uchar, | ||
arg6: ::std::os::raw::c_schar, | ||
) -> ::std::os::raw::c_int; | ||
} | ||
extern "C" { | ||
pub fn bar( | ||
arg1: ::std::os::raw::c_long, | ||
arg2: ::std::os::raw::c_longlong, | ||
) -> ::std::os::raw::c_long; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// bindgen-flags: --fit-macro-constant-types | ||
// Test fitting macro constants into smaller integer types | ||
// Negative values are i8, i16, i32 or i64; others are u8, u16, u32 or u64. | ||
#include "default-macro-constant-type.h" |