petsc4py.i is emitting wrapper code that triggers a warning/error if compiled using C++11

Issue #3 resolved
Johan Hake created an issue

The attached patch fixes the error. However, I wonder if the part triggering the error in petsc4py.i is still necessary for compiling a project against petsc4py. As the following fix (full removal) also seems work. I would prefer the inlined fix as the declared macro touches a huge amount of generated SWIG code not at all related to petsc4py.

--- a/src/include/petsc4py/petsc4py.i
+++ b/src/include/petsc4py/petsc4py.i
@@ -32,39 +32,6 @@ SWIG_convert_ptr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) {
 %}

 /* ---------------------------------------------------------------- */
-
-%runtime %{
-#define SWIG_ArgFail_Fmt(type, name, argn) \
-  "in method '" name"', argument "argn" of type '"type"'"
-#define SWIG_ArgNullRef_Fmt(type, name, argn) \
-  "invalid null reference "SWIG_ArgFail_Fmt(type, name, argn)
-#define SWIG_ArgOut_Fail_Fmt(type, name) \
-  "in method '"name"', output value of type '"type"'"
-#define SWIG_ArgIn_Fail(code, name, type, argn) \
-  SWIG_exception_fail(SWIG_ArgError(code),SWIG_ArgFail_Fmt(type, name, argn))
-#define SWIG_ArgNullRef_Fail(type, name, argn) \
-  SWIG_exception_fail(SWIG_ValueError,SWIG_ArgNullRef_Fmt(type, name, argn))
-#define SWIG_ArgOut_Fail(code,  type, name) \
-  SWIG_exception_fail(SWIG_ArgError(code), SWIG_ArgOut_Fail_Fmt(type, name))
-%}
-
-#undef  %argument_fail
-#undef  %argument_nullref
-#undef  %argout_fail
-#undef  %clear_output
-
-#define %argument_fail(code,_type,_name,_argn) \
-  SWIG_ArgIn_Fail(code,`_type`,`_name`,`_argn`)
-#define %argument_nullref(_type, _name, _argn) \
-  SWIG_ArgNullRef_Fail(`_type`,`_name`,`_argn`)
-#define %argout_fail(code,_type,_name) \
-  SWIG_ArgOut_Fail(code,`_name`,`_type`)
-#define %clear_output() Py_CLEAR($result)
-
-/* ---------------------------------------------------------------- */
-
-
-/* ---------------------------------------------------------------- */
 /* PETSc Error Codes                                                */

Comments (8)

  1. Johan Hake reporter

    Yes. With both patches and using SWIG development version.

    The patch that just insert some blanks (the attached) is the less intrusive to petsc4py. However the the inlined patch also works for our project and makes petsc4py.i much less intrusive to SWIG. the original petsc4py.i file overloads some internal swig macros (with no obvious reason) that are used all over the generate code.

  2. Lisandro Dalcin

    OK, give me some time to test the inlined patch. I do not remember the reason for overriding these internal macros, I wrote that code ages ago.

  3. Matthias Liertzer

    I just stumbled upon this bug with version 3.4 and it took me quite a while to figure out what's going wrong here. Could you maybe cherry-pick this change into the maint branch and maybe even release an updated 3.4 version? The reasoning for this is that this bug causes a compilaton error with the recently released gcc4.9 compared to a warning with 4.8.2.

  4. Log in to comment