There were several mistakes. For instance, the following line:
x := addback_struct_foo(...)
caused the error of dereferencing a void pointer.
I suggest that you use the following style:
(* ****** ****** *)
extern
castfn
takeout_struct_foo
{l:agz}
(
!struct_foo_ptr(l)
): (struct_foo@l, struct_foo@l -<lin,prf> void | ptr(l))
(* ****** ****** *)
//
extern
fun
struct_foo_get_b:
{l:agz}(!struct_foo_ptr(l)) -> int
//
implement
struct_foo_get_b (x) = ret where {
val (pf, fpf | p) = takeout_struct_foo (x)
val ret = p->b
prval () = fpf(pf)
}
//
(* ****** ****** *)
On Thursday, August 25, 2016 at 11:23:39 PM UTC-4, Kiwamu Okabe wrote:
>
> On Thu, Aug 25, 2016 at 11:41 PM, gmhwxi <...> wrote:
> > addback_struct_foo should be a prfun (instead of a castfn).
>
> I changed it as following, but the error is not fixed...
>
>
> https://github.com/jats-ug/practice-ats/commit/cd3693440273ae8b7bc429a898b7ac7c52e0f233
>
>
> ```
> $ patscc -o a.out main.dats -DATS_MEMALLOC_LIBC
> In file included from main_dats.c:15:0:
> main_dats.c: In function
> ‘_057_home_057_kiwamu_057_src_057_practice_055_ats_057_template_struct_057_gen_056_sats__struct_foo_get_b__3__1’:
>
>
> /home/kiwamu/src/ATS-Postiats/ccomp/runtime/pats_ccomp_instrset.h:207:29:
> warning: dereferencing ‘void *’ pointer
> #define ATSderef(pmv, hit) (*(hit*)pmv)
>
> /home/kiwamu/src/ATS-Postiats/ccomp/runtime/pats_ccomp_instrset.h:329:34:
> note: in definition of macro ‘ATSINSstore’
> #define ATSINSstore(pmv1, pmv2) (pmv1 = pmv2)
> ^~~~
> main_dats.c:1114:13: note: in expansion of macro ‘ATSderef’
> ATSINSstore(ATSderef(arg0, atsvoid_t0ype), tmp4__1) ;
> ^~~~~~~~
> main_dats.c:1114:1: error: invalid use of void expression
> ATSINSstore(ATSderef(arg0, atsvoid_t0ype), tmp4__1) ;
> ^~~~~~~~~~~
> ```
>
> Best regards,
> --
> Kiwamu Okabe at METASEPI DESIGN
>
--
You received this message because you are subscribed to the Google Groups
"ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/e4665061-1947-493f-ad1d-1bbb30af380a%40googlegroups.com.