|
From: David C. <da...@ar...> - 2006-11-16 03:46:24
|
Robert Kern wrote:
> David Cournapeau wrote:
>
>> Hi,
>>
>> This is a bit OT, but I wasted quite some time on this time, when
>> using 64 bits integers and ctypes on ubuntu edgy. As I know other people
>> use ubuntu with numpy, this may save some headache to others. I found
>> this behaviour which looks like a bug in ctypes for python2.5 on edgy
>> ubuntu:
>>
>> python2.5 -c "from ctypes import sizeof, c_longlong; print
>> sizeof(c_longlong)"
>>
>> prints 4 instead of 8, which in my case is problematic for
>> structures alignement. This affects only python2.5, and does not affect
>> a python installed from sources. Can anybody else reproduce this ?
>>
>
> Can you try a similar program in C compiled with the same C compiler that you
> used to build ctypes? sizeof(long long) does not have to be 8 bytes; it just has
> to be at least as large as sizeof(long).
>
>
I thought that ISO C99 required long long to be at least 64 bits, and
that gcc followed this by default:
#include <stdio.h>
int main(void)
{
printf("size of long long is %d\n", sizeof(long long));
return 0;
}
compiled by gcc with -W -Wall, returns 8. Gcc is edgy ubuntu, that is
4.1.2. I tried also with gcc 3.3 and 4.0, same result. Also, something I
didn't say is that c_int64 is not available from ctypes; with python2.4,
this is fine (I changed my code to use c_int64 instead: an import error
is much easier to find than a structure alignement problem when using
ctypes :) ).
Also, I insist on this point, installing python from sources returns 8,
as does python2.4 packaged by ubuntu (which is compiled by the exact
same compiler according to python prompts). I am now trying to see if
this is coming from configuration options (now, I know what a dual cpu
is useful for: compiling python with make -j5 is really fast:) ),
cheers,
David
|