Re: generated wrapper code contains errors in arrays of dimension > 2
William S Fulton <[email protected]> Fri, 28 Apr 2023 18:01:56 +0100
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CANGqftAcS5t6+CTKbV=M0Y_f90g1v_+R8P2yfvpKhmiUmEL_Cg@mail.gmail.com> |
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]> 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]
> https://lists.sourceforge.net/lists/listinfo/swig-user
>
_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user