This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年07月26日 07:24 by Mike.Castle, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| t.py | Mike.Castle, 2012年07月26日 07:24 | |||
| t.c | Mike.Castle, 2012年07月26日 07:25 | |||
| Messages (4) | |||
|---|---|---|---|
| msg166462 - (view) | Author: Mike Castle (Mike.Castle) | Date: 2012年07月26日 07:24 | |
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). |
|||
| msg166463 - (view) | Author: Mike Castle (Mike.Castle) | Date: 2012年07月26日 07:25 | |
And the C version.... |
|||
| msg166621 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2012年07月28日 00:00 | |
If you have not, please check other ctypes bitfields issues, especially #15119 "ctypes mixed-types bitfield layout nonsensical; doesn't match compiler." to see if this is the same problem. |
|||
| msg167078 - (view) | Author: Mike Castle (Mike.Castle) | Date: 2012年08月01日 03:09 | |
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. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:33 | admin | set | github: 59658 |
| 2021年03月12日 21:11:59 | eryksun | set | status: open -> closed superseder: [Linux] ctypes packs bitfields Incorrectly resolution: duplicate stage: resolved |
| 2018年04月01日 22:36:33 | martin.panter | link | issue22781 superseder |
| 2012年08月01日 03:09:32 | Mike.Castle | set | messages: + msg167078 |
| 2012年07月28日 00:00:41 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg166621 versions: - Python 2.6 |
| 2012年07月26日 07:42:18 | mark.dickinson | set | nosy:
+ mark.dickinson, meador.inge |
| 2012年07月26日 07:25:54 | Mike.Castle | set | files:
+ t.c messages: + msg166463 |
| 2012年07月26日 07:24:57 | Mike.Castle | create | |