CTypes on a 64 bit machine truncates pointers to 32 bits?

R

Ron Garret

CTypes on a 64-bit machine appears to be truncating pointers to 32 bits:

[ron@monster1:~]$ uname -a
Linux monster1 2.6.18-6-amd64 #1 SMP Mon Jun 16 22:30:01 UTC 2008 x86_64
GNU/Linux
[ron@monster1:~]$ cat foo.c
void* foo(void* x) { return x; }
[ron@monster1:~]$ gcc -fPIC -shared foo.c -o foo.so
[ron@monster1:~]$ file foo.so
foo.so: ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not
stripped
[ron@monster1:~]$ python
Python 2.5 (release25-maint, Jul 23 2008, 18:15:29)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
I am aware of http://bugs.python.org/issue1703286 but I get the same
result in Python2.5.2:

[ron@monster1:~]$ py252/bin/python
Python 2.5.2 (r252:60911, Sep 18 2008, 10:48:29)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 
R

Ron Garret


Shouldn't you tell ctypes that the argument and the result
of foo is a pointer?[/QUOTE]

Yeah... that's it. Default return type is int, which I assumed would be
64 bits on a 64 bit machine, but turns out it's 32. Stupid.

rg
 
L

Lawrence D'Oliveiro

Default return type is int, which I assumed would be
64 bits on a 64 bit machine, but turns out it's 32. Stupid.

I think preferred ABIs these days are LP64, not ILP64 or LLP64.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top