-
Notifications
You must be signed in to change notification settings - Fork 707
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #1008 - AndrewGaspar:underscore-identifier, r=fitzgen
Translate _ as __ This change treats _ as a reserved identifier to resolve the bug reported in #631. I have one concern - if the header has both an `_` and `__` identifier in the global namespace, this will cause a conflict. However, it seems like we already don't handle that case for `keyword_` (e.g. `abstract_`, `alignof_`, etc.) so it doesn't seem like we need a solution specifically for `__` in this change. Fixes #631.
- Loading branch information
Showing
3 changed files
with
45 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* automatically generated by rust-bindgen */ | ||
|
||
|
||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] | ||
|
||
|
||
pub const __: ::std::os::raw::c_int = 10; | ||
#[repr(C)] | ||
#[derive(Debug, Default, Copy)] | ||
pub struct ptr_t { | ||
pub __: [::std::os::raw::c_uchar; 8usize], | ||
} | ||
#[test] | ||
fn bindgen_test_layout_ptr_t() { | ||
assert_eq!( | ||
::std::mem::size_of::<ptr_t>(), | ||
8usize, | ||
concat!("Size of: ", stringify!(ptr_t)) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<ptr_t>(), | ||
1usize, | ||
concat!("Alignment of ", stringify!(ptr_t)) | ||
); | ||
assert_eq!( | ||
unsafe { &(*(0 as *const ptr_t)).__ as *const _ as usize }, | ||
0usize, | ||
concat!( | ||
"Alignment of field: ", | ||
stringify!(ptr_t), | ||
"::", | ||
stringify!(__) | ||
) | ||
); | ||
} | ||
impl Clone for ptr_t { | ||
fn clone(&self) -> Self { | ||
*self | ||
} | ||
} |
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,3 @@ | ||
const int _ = 10; | ||
|
||
typedef struct { unsigned char _[8]; } ptr_t; |