C macro expansion problem (was: dbus-python 0.82.1)
Eyal Ben David
Eyal.BenDavid at expand.com
Thu Jul 12 04:13:09 PDT 2007
Hello all,
(My environment is CentOS3 with locally built python 2.4.4 and
dbus-1.0.2 and gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-53)
When trying to build this version (and any 0.8x too) I get the following
error in 3 files:
---
containers.c:257:1: directives may not be used inside a macro argument
containers.c:256:1: unterminated argument list invoking macro
"PyDoc_STRVAR"
containers.c:274: syntax error before string constant
containers.c:455: `Dict_tp_doc' undeclared here (not in a function)
containers.c:455: initializer element is not constant
containers.c:455: (near initialization for `DBusPyDict_Type.tp_doc')
---
I had to patch the source code in order to build cleanly.
My patch is not good for a general purpose release but I attach it here
anyway.
I guess older gcc versions (actually the preprocessor) don't allow
#ifdef inside a macro. When I used gcc 4.1 the release was built OK.
Thanks
Eyal
------------ CUT HERE ----------
diff -ru dbus-python-0.81.1-orig/_dbus_bindings/containers.c dbus-
python-0.81.1/_dbus_bindings/containers.c
--- dbus-python-0.81.1-orig/_dbus_bindings/containers.c 2007-04-30
13:01:39.000000000 +0300
+++ dbus-python-0.81.1/_dbus_bindings/containers.c 2007-06-22
03:51:42.000000000 +0300
@@ -254,9 +254,7 @@
"``signature`` is either a string or None. If a string, it must consist
\n"
"of exactly two complete type signatures, representing the 'key' type
\n"
"(which must be a primitive type, i.e. one of \"bd"
-#ifdef WITH_DBUS_FLOAT32
"f"
-#endif
"ginoqstuxy\")\n"
"and the 'value' type. The signature of the whole Dictionary will be\n"
"``a{xx}`` where ``xx`` is replaced by the given signature.\n"
diff -ru dbus-python-0.81.1-orig/_dbus_bindings/int.c dbus-
python-0.81.1/_dbus_bindings/int.c
--- dbus-python-0.81.1-orig/_dbus_bindings/int.c 2007-04-30
13:01:39.000000000 +0300
+++ dbus-python-0.81.1/_dbus_bindings/int.c 2007-06-22
03:56:00.000000000 +0300
@@ -505,13 +505,7 @@
"\n"
"This type only works on platforms where the C compiler has suitable\n"
"64-bit types, such as C99 ``long long``.\n"
-#ifdef DBUS_PYTHON_64_BIT_WORKS
"This is the case on your current platform.\n"
-#else /* !defined(DBUS_PYTHON_64_BIT_WORKS) */
- "This is not the case on your current platform, so this type's\n"
- "constructor will always raise NotImplementedError. Try a better\n"
- "compiler, if one is available.\n"
-#endif /* !defined(DBUS_PYTHON_64_BIT_WORKS) */
"\n"
"Constructor::\n"
"\n"
@@ -620,13 +614,7 @@
"\n"
"This type only exists on platforms where the C compiler has suitable
\n"
"64-bit types, such as C99 ``unsigned long long``.\n"
-#ifdef DBUS_PYTHON_64_BIT_WORKS
"This is the case on your current platform.\n"
-#else /* !defined(DBUS_PYTHON_64_BIT_WORKS) */
- "This is not the case on your current platform, so this type's\n"
- "constructor will always raise NotImplementedError. Try a better\n"
- "compiler, if one is available.\n"
-#endif /* !defined(DBUS_PYTHON_64_BIT_WORKS) */
"\n"
"Constructor::\n"
"\n"
More information about the dbus
mailing list