Re: feature request for setting _pack_ to a higher value

Axel Seibert <[email protected]>
Newsgroups gmane.comp.python.ctypes
Message-ID <[email protected]>
Hi, Mads, dear list!

> Can you give an (or several) exact example of a problematic C 
> declaration and what you would have hoped worked with ctypes and how you 
> have to workaround?


I don't think I expected some magic bullet from ctypes, I just had not expected so many problems when changing from Windows to Linux. And, ctypes already has already in there that I need -- there is just one check within ctypes that makes my workaround currently impossible.

This is an excerpt from the python that the code generation created for me from the header file. They are the same under windows & linux.

STRING = c_char_p
ARLong32 = c_long
ARULong32 = c_ulong
ARTimestamp = ARLong32
ARTime = ARLong32

class ARValueStruct(Structure):
    pass
    _pack_ = 8
class N13ARValueStruct3DOT_1E(Union):
    pass
N13ARValueStruct3DOT_1E._fields_ = [
    ('noval_', size_t),
    ('keyNum', c_uint),
    ('intVal', ARLong32),
    ('realVal', c_double),
    ('charVal', STRING),
    ('diaryVal', STRING),
    ('enumVal', ARULong32),
    ('timeVal', ARTimestamp),
    ('maskVal', ARULong32),
    ('timeOfDayVal', ARTime),
    ('byteListVal', POINTER(ARByteList)),
    ('decimalVal', STRING),
    ('attachVal', POINTER(ARAttachStruct)),
    ('ulongVal', ARULong32),
    ('coordListVal', POINTER(ARCoordList)),
    ('dateVal', c_int),
    ('currencyVal', POINTER(ARCurrencyStruct)),
    ('ptrVal', c_void_p),
]
ARValueStruct._fields_ = [
    ('dataType', c_uint),
    ('u', N13ARValueStruct3DOT_1E),
]

I think, I can leave out the definition of ARByteList, and the other structs...

Now, this works fine under Windows (32bit), Solaris (32bit), but it fails under Linux (32bit). Only when I
set _pack_= 8 for both structs, it will also work under Linux. But ctypes (at least under Python 2.6.4) does not allow me to set _pack_ to a value higher than 4 under 32 bit Linux.

> A reference to the Thomas quote might help the discussion too.

http://www.gossamer-threads.com/lists/engine?do=post_view;post=700673;list=python

Thanx,
Axel


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.