Re: generated wrapper code contains errors in arrays of dimension > 2
"Montare, Aidan A. \(Fed\) via Swig-user" <[email protected]> Fri, 5 May 2023 20:45:45 +0000
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <BY3PR09MB8596EC59847A4E33911605C889729@BY3PR09MB8596.namprd09.prod.outlook.com> |
Thanks for the suggestion! I'll give this a try when I get back to implementing that part of the library. Best wishes, Aidan Montare (she/her) Time Realization and Distribution Group Time and Frequency Division NIST Boulder From: William S Fulton <[email protected]> Sent: Friday, April 28, 2023 11:02 AM To: Montare, Aidan A. (Fed) <[email protected]> Cc: [email protected] Subject: Re: [Swig-user] generated wrapper code contains errors in arrays of dimension > 2 Hi Aidan You need to write a typemap for this. Copy and modify the SWIGTYPE[ANY][ANY] typemaps for what you want. Editing code by hand is never ideal. Alternative workaround is to ignore the variable with %ignore and add in some C getters/setters which will wrap using default typemaps: %inline %{ void setX(int i, int j, int k, double val) { X[i][j][k] = val; } void getX(int i, int j, int k) { return X[i][j][k]; } %} William On Thu, 27 Apr 2023 at 20:11, Montare, Aidan A. (Fed) via Swig-user <[email protected]<mailto:[email protected]>> wrote: Hi, I'm a new user of SWIG, and ran across an issue that seems to have be documented before: https://github.com/swig/swig/issues/142 (from that thread:) """Array with more than two dimensions, e.g. extern double x[2][3][4]; lead to wrapped code with compile errors: swig_wrap.c: In function '_wrap_x_set': swig_wrap.c:2425:50: error: incompatible types when assigning to type 'double[4]' from type 'double' for (; jj < (size_t)3; ++jj) x[ii][jj] = inp[ii][jj]; ^ """ I was just wondering if anyone has found workarounds for this issue, or if there has been any progress on it since that issue was last commented on. At the moment, since I only have one single case of this in the library I'm trying to wrap, I'm considering modifying the generated wrappers by hand. I'd be interested in submitting a pull request to SWIG if I were able to fix the issue more generally, but I don't think I'm experienced enough to be able to do that yet. Best wishes, Aidan Montare (she/her) Time Realization and Distribution Group Time and Frequency Division NIST Boulder _______________________________________________ Swig-user mailing list [email protected]<mailto:[email protected]> https://lists.sourceforge.net/lists/listinfo/swig-user _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user