You are right, including "
share/atspre_staload.hats" causes the code to compile. However, I'm still having issues. You see, the code I provided I had taken from a static (.sats) and dynamic (.dats) file in order to make it more presentable when asking for help. Your fix only fixes the issue in the single-file version, and when including the external static file it doesn't work. Do you know what might be going wrong? I'll provide the (simplified) contents of each of these files below.
dict.sats:
#include "share/atspre_staload.hats"
datavtype BUCKET (a:vt@ype) =
| bucket_empty of ()
| bucket_filled of (Strptr1, a, BUCKET(a))
vtypedef bucket(a:vt@ype) = BUCKET(a)
fn{a:vt@ype} bucket_item$delete ( x: a ): void
fun{a:vt@ype} bucket_delete_recursive ( b: bucket(a) ) : void
sortdef dsz = {s:int | s > 0}
vtypedef dict(a:vt@ype, n:int) =
@{
size=int n,
buckets=arrayptr(bucket(a), n)
}
fn{a:vt@ype} dict_new {s:dsz} ( int s ) : dict(a, s)
fn{a:t@ype} dict_delete {s:dsz} ( d: dict(a, s) ) : void
fn{a:vt@ype} dict_delete_lin {s:dsz} ( d: dict(a, s) ) : void
dict.dats:
#include "share/atspre_staload.hats"
staload "./dict.sats"
local
in
end
dict_test.dats, where main is:
#include "share/atspre_staload.hats"
staload "./dict.sats"
implmnt main0 () = let
var d = dict_new<int>(13)
in
dict_delete(d)
end
My output:
$ patscc --gline -DATS_MEMALLOC_LIBC dict_test.dats
In file included from dict_test_dats.c:15:
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats: In function ‘mainats_0_void’:
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:21: error: ‘PMVtmpltcstmat’ undeclared (first use in this function)
58 | var d = dict_new<int>(13)
| ^~~~~~~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
276 | #define ATSINSmove(tmp, val) (tmp = val)
| ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:21: note: each undeclared identifier is reported only once for each function it appears in
58 | var d = dict_new<int>(13)
| ^~~~~~~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
276 | #define ATSINSmove(tmp, val) (tmp = val)
| ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:39: error: ‘dict_new’ undeclared (first use in this function)
58 | var d = dict_new<int>(13)
| ^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
276 | #define ATSINSmove(tmp, val) (tmp = val)
| ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:48: warning: implicit declaration of function ‘S2Eapp’ [-Wimplicit-function-declaration]
58 | var d = dict_new<int>(13)
| ^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
276 | #define ATSINSmove(tmp, val) (tmp = val)
| ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:55: warning: implicit declaration of function ‘S2Ecst’ [-Wimplicit-function-declaration]
58 | var d = dict_new<int>(13)
| ^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
276 | #define ATSINSmove(tmp, val) (tmp = val)
| ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:62: error: ‘g0int_t0ype’ undeclared (first use in this function)
58 | var d = dict_new<int>(13)
| ^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
276 | #define ATSINSmove(tmp, val) (tmp = val)
| ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:74: error: expected ‘)’ before ‘;’ token
58 | var d = dict_new<int>(13)
| ^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
276 | #define ATSINSmove(tmp, val) (tmp = val)
| ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:101: error: expected expression before ‘)’ token
58 | var d = dict_new<int>(13)
| ^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
276 | #define ATSINSmove(tmp, val) (tmp = val)
| ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:60:44: error: ‘dict_delete’ undeclared (first use in this function); did you mean ‘timer_delete’?
60 | dict_delete(d)
| ^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: note: in definition of macro ‘ATSINSmove_void’
284 | #define ATSINSmove_void(tmp, command) command
| ^~~~~~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:60:82: error: expected ‘)’ before ‘;’ token
60 | dict_delete(d)
| ^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: note: in definition of macro ‘ATSINSmove_void’
284 | #define ATSINSmove_void(tmp, command) command
| ^~~~~~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:60:109: error: expected expression before ‘)’ token
60 | dict_delete(d)
| ^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: note: in definition of macro ‘ATSINSmove_void’
284 | #define ATSINSmove_void(tmp, command) command
| ^~~~~~~