Comments (8)
Which rust version are you using? We have code to deal with this, see a380678
from rust-bindgen.
Ah, so I couldn't repro this, but that's because for some reason --target=x86_64-pc-win32
is needed to repro:
./target/debug/bindgen --with-derive-default t.h -- --target=x86_64-pc-win32
Is the command I used to reproduce. It seems the MONITORINFO;
line is kind of like a member, but it's unnamed and clang doesn't expose it as such... o.O
from rust-bindgen.
And somehow that only happens when targeting windows
from rust-bindgen.
I think that limitation in rustc is mostly historical? rust-lang/rust#124163 removes it.
from rust-bindgen.
Which rust version are you using? We have code to deal with this, see a380678
I'm able to repro on latest stable(stable-x86_64-pc-windows-msvc unchanged - rustc 1.77.2 (25ef9e3d8 2024-04-09)
), beta(beta-x86_64-pc-windows-msvc updated - rustc 1.78.0-beta.7 (6fd191292 2024-04-12) (from rustc 1.78.0-beta.5 (9eff51035 2024-04-06))
), and nightly(nightly-x86_64-pc-windows-msvc updated - rustc 1.79.0-nightly (e3181b091 2024-04-18) (from rustc 1.79.0-nightly (8b2459c1f 2024-04-09))
). I'm assuming this is some sort of regression.
Ah, so I couldn't repro this, but that's because for some reason --target=x86_64-pc-win32 is needed to repro:
I am using x64 windows w/ msvc toolchain, so my native target is x86_64-pc-windows-msvc
I've also tried enabling clang's msvc compat, and it doesn't alter behavior here:
.clang_args([
"-fms-compatibility",
"-fms-extensions",
"-fdelayed-template-parsing",
])
from rust-bindgen.
@emilio looks like your proposed patch to rust was rejected. Can this continue to be handled by bindgen?
from rust-bindgen.
I think this issue is a bit deeper than just a missing Default
implementation. If we had something like this:
// hello.c
typedef struct bar {
int *a[17];
} bar;
typedef struct foo {
bar;
int b;
} foo;
and ran bindgen hello.c --with-derive-default --no-layout-tests -- --target=x86_64-pc-windows-mvsc -fms-extensions
you'd get:
/* automatically generated by rust-bindgen 0.69.4 */
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct bar {
pub a: [*mut ::std::os::raw::c_int; 17usize],
}
impl Default for bar {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[repr(align(8))]
#[derive(Debug, Default, Copy, Clone)]
pub struct foo {
pub __bindgen_padding_0: [u32; 34usize],
pub b: ::std::os::raw::c_int,
}
implementing Default
for foo
is most likely wrong as you'd end up with an array of null pointers. I guess this is just a symptom of clang
exposing the anonymous struct inside foo
as an opaque type instead of giving the proper information.
from rust-bindgen.
bruh
from rust-bindgen.
Related Issues (20)
- wrap-static-fns converts _Bool to bool, causing a compile error HOT 3
- Clippy warns of useless_transmute in bitfields' setters and getters HOT 2
- Blocklist/allowlist based on header HOT 2
- Simplify target conversion further
- UINTMAX64 can never be generated HOT 2
- can not get the non-type template arg?
- allowlist_item does not work for anonymous enums - allowlist_var does HOT 1
- --target=wasm32-unknown-unknown: 'stdio.h' file not found HOT 5
- Unable to generate bindings for Arduino library IRremote.hpp on MacOS HOT 1
- Thread panicking at bindgen .Err state unable to found libclang.dll but it available on the path variable HOT 2
- feature request: Enable deriving `Clone`, `Copy`, etc... for `__IncompleteArrayField` and containing structs. HOT 2
- Support for raw-dylib for Windows
- Support for one set of bindings depending on another (conflicting `__BindgenBitfieldUnit`) HOT 3
- Unable to run bindgen on ubuntu 22.04 HOT 2
- update requirements for OpenBSD HOT 10
- Building tests for LightGBM bindings failes with linker error
- Unable to prevent Clang headers from being used
- Update clang-sys HOT 2
- AArch64 Linux va_list not FFI-safe
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-bindgen.