Re: SWIG: GCC compile errors with unsigned char when using the compactdefaultargs or kwargs feature
William S Fulton <[email protected]>
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CANGqftCPdff-CThtYSXq6iJSJNkwyJcXKTpg_aJWWrSg4+KeVg@mail.gmail.com> |
On Fri, 12 Jun 2020 at 08:08, Terry Barnaby <[email protected]> wrote: > Hi, > > I have an error appearing during compilation of the SWIG output file > when I try to use either or both of the "compactdefaultargs" and > "kwargs" features when using unsigned char's. > > This is with swig-4.0.1-3.fc31.src.rpm and GCC 9.3.1 on Fedora31. > > I get the GCC error: > > bds_wrap.cpp: In function ‘PyObject* _wrap_new_BArrayBUInt8(PyObject*, > PyObject*, PyObject*)’: > bds_wrap.cpp:2947:40: error: expected primary-expression before ‘unsigned’ > 2947 | unsigned char arg1 = (unsigned char) unsigned char() ; > > A simple example is shown below. If I use single keyword types like > "int", "char" all is fine. > > Any idea what I am doing wrong (G++ options or is this a bug in SWIG ) ? > > Terry > > > /******************************************************************************* > * Test1.swig Shows an error > > ******************************************************************************* > */ > %module bdslib > > %feature("compactdefaultargs"); > %feature("kwargs"); > > The "compactdefaultargs" feature has some flaws and this is one of them. The primary flaw is documented at http://swig.org/Doc4.0/SWIGPlus.html#SWIGPlus_default_args. Just selectively turn them off BArray by replacing the above two lines with: %feature("compactdefaultargs"); %feature("compactdefaultargs", "0") BArray; %feature("kwargs"); %feature("kwargs", "0") BArray; William _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user