who can tell me the difference in ctypes.sizeof between Ironpython and python in using ctypes to create structure?
"狂禅" <[email protected]> Wed, 11 Mar 2015 10:49:46 +0800
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <[email protected]> |
recently i meet a problem in using Ironpython.
import ctypes as ct
class Data(ct.LittleEndianStructure):
_pack_ = 2
_fields_ = [
('a',ct.c_ubyte),
('b',ct.c_ubyte),
('c',ct.c_ubyte),
('d',ct.c_ushort),
('e',ct.c_uint),
('f',ct.c_ubyte),
]
if __name__ == "__main__":
a = Data()
print ct.sizeof(a)
as is show above.when i used this script running in python ,it prints 12.
but when running in Ironpython ,it is 14.
in fact ,i tried it in c like that:
#include<stdio.h>
void main()
{
#pragma pack(2)
struct{
unsigned char a;
unsigned char b;
unsigned char c;
unsigned short d;
unsigned int e;
unsigned char f;
}A;
#pragma pack()
printf("%d\n",sizeof(A));
}
it is 12.
can you tell me why it is and how i can crrect it in Ironpython???
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
ctypes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ctypes-users