Unbox array @ doesn't construct memory. It causes SEGV. (#90)

It causes SEGV. (#90)
reply+i-42844433-1baf5a9942cb121...@reply.github.com

Mapping ATS types to C types can be difficult, sometimes.

I suggest the following approach:

%{^
typedef
struct {
int m0;
int m1[128];
int m2[128];
} mystruct;
%}

typedef
mystruct =
$extype_struct"mystruct"of{
m0 = int, m1 = @[int][128], m2= @[int][128]
}On Tue, Sep 16, 2014 at 12:57 AM, Kiwamu Okabe notifi...@github.com wrote:

I think following should be also available…

#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”

vtypedef mystruct = @{
m0 = int
, m1 = @[int][128]
, m2 = @[int][128]
}

implement main0 () = {
var stA: mystruct
}

$ patscc main.dats
exec(patsopt --output main_dats.c --dynamic main.dats)
exec(patsopt --output main_dats.c --dynamic main.dats) = 0
exec(gcc -std=c99 -D_XOPEN_SOURCE -I${PATSHOME} -I${PATSHOME}/ccomp/runtime -L${PATSHOME}/ccomp/atslib/lib -L${PATSHOME}/ccomp/atslib/lib64 main_dats.c)
main_dats.c:211:29: error: flexible array member not at end of struct
atstkind_t0ype(atstype_int) atslab__m1;
^
exec(gcc -std=c99 -D_XOPEN_SOURCE -I${PATSHOME} -I${PATSHOME}/ccomp/runtime -L${PATSHOME}/ccomp/atslib/lib -L${PATSHOME}/ccomp/atslib/lib64 main_dats.c) = 256


Reply to this email directly or view it on GitHub
https://github.com/githwxi/ATS-Postiats/issues/90#issuecomment-55695859.