Hi,
Sigrok can't compile with Python 3+.
It fails with the following error:
..
decode.c:72:2: warning: implicit declaration of function
'PyString_Check'
decode.c:80:2: warning: implicit declaration of function
'PyString_AsString'
decode.c:80:12: warning: assignment makes pointer from integer without
a cast
decode.c: In function 'sigrokdecode_load_decoder':
decode.c:118:2: warning: implicit declaration of function
'PyString_FromString'
decode.c:118:16: warning: assignment makes pointer from integer
without a cast
..
/home/olivier/dev/contrib/sigrok/libsigrokdecode/.libs/libsigrokdecode.so:
undefined reference to `PyString_AsString'
/home/olivier/dev/contrib/sigrok/libsigrokdecode/.libs/libsigrokdecode.so:
undefined reference to `PyString_FromString'
/home/olivier/dev/contrib/sigrok/libsigrokdecode/.libs/libsigrokdecode.so:
undefined reference to `PyString_Check'
..
Python docs tells us more about String functions:
"These functions have been renamed to PyBytes_* in Python 3.x. Unless
otherwise noted, the PyBytes functions available in 3.x are aliased to
their PyString_* equivalents to help porting."
( http://docs.python.org/c-api/string.html )
The attached patch fixes the compilation errors.
Olivier
--
Olivier Fauchon
www.oflabs.com
diff --git a/libsigrokdecode/decode.c b/libsigrokdecode/decode.c
index 1b12c9e..20d6bb6 100644
--- a/libsigrokdecode/decode.c
+++ b/libsigrokdecode/decode.c
@@ -22,6 +22,15 @@
#include <stdio.h>
#include <string.h>
+
+
+/* re-define some String functions for recent python (>= 3.0) */
+#if PY_VERSION_HEX >= 0x03000000
+#define PyString_AsString PyBytes_AsString
+#define PyString_FromString PyBytes_FromString
+#define PyString_Check PyBytes_Check
+#endif
+
/**
* Initialize libsigrokdecode.
*
------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web. Learn how to
best implement a security strategy that keeps consumers' information secure
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel