Message75793
'''
http://docs.python.org/dev/3.0/library/ctypes.html
Where web page says
>>> printf("An int %d, a double %f\n", 1234, c_double(3.14))
Integer 1234, double 3.1400001049
31
>>>
should instead read
>>> printf(c_char_p("An int %d, a double %f\n"), 1234, c_double(3.14))
An int 1234, a double 3.140000
31
Although the intent of the message is clear, it is inexact with
regard to "An int" and "a double". Core dump is bigger problem:
Processor: Dual-Core AMD Opteron(tm) Processor 2218
Python: Python 3.0rc1+ (py3k, Nov 5 2008, 14:44:46)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
core dumps by segmentation fault for all the printf examples without
specifying c_char_p("string").
'''
# this program succeeds
from ctypes import *
libc = CDLL("libc.so.6")
print(libc.printf(c_char_p("An int %d, a double %f\n"), 1234,
c_double(3.14))) |
|
Date |
User |
Action |
Args |
2008-11-12 20:53:15 | LambertDW | set | recipients:
+ LambertDW, georg.brandl |
2008-11-12 20:53:14 | LambertDW | set | messageid: <1226523194.83.0.190505447778.issue4309@psf.upfronthosting.co.za> |
2008-11-12 20:53:12 | LambertDW | link | issue4309 messages |
2008-11-12 20:53:11 | LambertDW | create | |
|