Dear all,
I wrote following code:
```ats
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"
#define MAXPATHLEN 1024
typedef kld_file_stat = @{ version = int, name = @[char][MAXPATHLEN]}
fun kern_kldstat {l:addr} (pf: !kld_file_stat @ l | p: ptr l): int = 0 where {
val () = !p.name.[0] := 'A'
}
implement main0 () = {
}
```
But it causes following compile error:
```
$ patscc -D_GNU_SOURCE -DATS_MEMALLOC_LIBC main.dats -lpthread
main_dats.c:122:1: warning: parameter names (without types) in
function declaration
122 | atstkind_t0ype(atstype_char) atstyarr_field(atslab__name) ;
| ^~~~~~~~~~~~~~
In file included from main_dats.c:14:
/home/kiwamu/src/ATS-Postiats/ccomp/runtime/pats_ccomp_typedefs.h:176:31:
error: field ‘atstyarr_field_undef’ declared as a function
176 | #define atstyarr_field(fname) atstyarr_field_undef(fname)
| ^~~~~~~~~~~~~~~~~~~~
main_dats.c:122:30: note: in expansion of macro ‘atstyarr_field’
122 | atstkind_t0ype(atstype_char) atstyarr_field(atslab__name) ;
| ^~~~~~~~~~~~~~
main_dats.c:127:1: warning: parameter names (without types) in
function declaration
127 | atstkind_t0ype(atstype_char) atstyarr_field(atslab__name) ;
| ^~~~~~~~~~~~~~
In file included from main_dats.c:14:
/home/kiwamu/src/ATS-Postiats/ccomp/runtime/pats_ccomp_typedefs.h:176:31:
error: field ‘atstyarr_field_undef’ declared as a function
176 | #define atstyarr_field(fname) atstyarr_field_undef(fname)
| ^~~~~~~~~~~~~~~~~~~~
main_dats.c:127:30: note: in expansion of macro ‘atstyarr_field’
127 | atstkind_t0ype(atstype_char) atstyarr_field(atslab__name) ;
| ^~~~~~~~~~~~~~
In file included from main_dats.c:15:
main_dats.c: In function ‘kern_kldstat_0’:
/home/kiwamu/src/ATS-Postiats/ccomp/runtime/pats_ccomp_instrset.h:226:45:
error: ‘postiats_tyrec_0’ has no member named ‘atslab__name’
226 | #define ATSSELfltrec(pmv, tyrec, lab) ((pmv).lab)
| ^
/home/kiwamu/src/ATS-Postiats/ccomp/runtime/pats_ccomp_instrset.h:339:34:
note: in definition of macro ‘ATSINSstore’
339 | #define ATSINSstore(pmv1, pmv2) (pmv1 = pmv2)
| ^~~~
main_dats.c:218:13: note: in expansion of macro ‘ATSSELarrptrind’
218 | ATSINSstore(ATSSELarrptrind(ATSSELfltrec(ATSderef(arg0,
postiats_tyrec_0), postiats_tyrec_1, atslab__name),
atstkind_t0ype(atstype_char), [ATSPMVi0nt(0)]), ATSPMVchar('A')) ;
| ^~~~~~~~~~~~~~~
main_dats.c:218:29: note: in expansion of macro ‘ATSSELfltrec’
218 | ATSINSstore(ATSSELarrptrind(ATSSELfltrec(ATSderef(arg0,
postiats_tyrec_0), postiats_tyrec_1, atslab__name),
atstkind_t0ype(atstype_char), [ATSPMVi0nt(0)]), ATSPMVchar('A')) ;
| ^~~~~~~~~~~~
make: *** [../../../../../../mk/
ats2-fix.mk:2: all] Error 1
```
How to define array members in typedef using pure ATS language?
Or should we use the following idiom with C language?
https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/TESTATS/fieldarr.dats#L20
Best regards,
--
Kiwamu Okabe at METASEPI DESIGN