-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
packed structs #352
Comments
We can get the alignment of a struct using this function long long clang_Type_getAlignOf(CXType T); and use it for annotation Do we need any other config for this? EDIT: Will this be platform-independent though? Can this value be different on different platforms? |
I don't think always emitting @PACKED aways is platform independent. Ideally, we would only emit If we can't detect if packing is used from clang, then we might want to use a configuration option to specify packing instead. |
We can only use the There are 3 ways to specify how a struct is packed in C -
I think this covers everything, |
P.S. A good stresstest would be to compare the generated bindings with the ones that @timsneath has been generating from the win32 meta-data repository in https://github.com/timsneath/win32. (I'm sure the metadata repository has more information than the C header files, so ffigen might not be as precise, but it would be cool to see if we end up with the same generated bindings.) |
We will have to also provide users a way to specify the packing via the config since -
The config can be something like this - structs:
pack:
'ShortStruct': 2 # value can be [0, 1, 2, 4, 8 ,16]. 0 means no packing is applied.
'.*': 1
'NotPackedStruct': 0 This allows users to override the generated values, so this config will only be needed if the generated |
Maybe use And yes an option for |
In my Win32 code, structs.g.dart represents all the structs I'm able to generate automatically today; structs.dart represents all the structs I still have to generate manually (mostly because of the lack of union support). |
Thanks @timsneath I'll take a look. |
* WIP: NSData bug repro * Fix forward declaration bug * Remove unused clang_isDeclaration function * Format
2.13.0-211.6.beta
has support for packed structs (dart-lang/sdk#38158).Can we detect with clang a struct is packed? and add the right annotation to it?
The text was updated successfully, but these errors were encountered: