-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
ctype with packed bitfields does not match native compiler #59658
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
Comments
On debian/testing with python 2.7.3rc2 and gcc 4.7.1. I was trying to use ctypeslib to wrap libdvdnav and running into some issues porting my test C code to Python, eventually tracking it down to this difference between how ctypes and gcc handles bitfields in packed structs (i.e., affects real world problems). Basically, by default, gcc treats 8, 16 and 32 bit types in bit fields as 1 byte when using __attribute__ ((packed)) , while ctypes treats them each as 1, 2 and 4 bytes even when using _pack_ = 1. (and libdvdnav using packed a lot) Output from the attached programs: $ ./a.out
1
1
1
$ ./t.py
1
2
4 Removing the packed attribute or building with gcc -mms-bitfields both match the ctypes expectations (though -mms-bitfields is probably rarely used in Linux). |
And the C version.... |
If you have not, please check other ctypes bitfields issues, especially bpo-15119 "ctypes mixed-types bitfield layout nonsensical; doesn't match compiler." to see if this is the same problem. |
I did read through all of those before posting this one. As far as I can remember, none of those addressed the use of pack, which is the sole problem I'm facing here. Now maybe when all is said and done and all of these bitfield bugs are worked out, this one and that one will both be fixed. But I wasn't sure if this example would clarify or cloud those issues. |
This issue is now being tracked at #73939. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: