Hi all,
Now, I'm porting ATS programming environment into tiny chip named ESP8266.
https://github.com/fpiot/esp8266-ats
And I'm trying to use strptr on the platform.
```
$ vi esp8266-ats/ESP8266_PRELUDE/CATS/memalloc.cats
#ifndef ATSLIB_PRELUDE_CATS_MEMALLOC
#define ATSLIB_PRELUDE_CATS_MEMALLOC
void atsruntime_mfree_undef (void *ptr) {
os_free(ptr);
return;
}
void *atsruntime_malloc_undef (size_t bsz) {
return ((void *)os_malloc(bsz));
}
#endif // ifndef ATSLIB_PRELUDE_CATS_MEMALLOC
$ vi esp8266-ats/ESP8266_PRELUDE/kernel_prelude.cats
--snip--
#include "ESP8266_PRELUDE/CATS/memalloc.cats"
$ vi esp8266-ats/dweet_ats/user/user_main.dats
--snip--
implement tcp_connected (arg) = {
val temperature = 55 (* test data *)
val conn = $UN.cast{cPtr1(espconn_t)}(arg)
val () = println! "tcp_connected()"
val _ = espconn_regist_recvcb (conn, data_received)
val json_data = string0_append ("{\"temperature\": ", "")
val () = free json_data
--snip--
```
However the code occurs following compile error:
```
$ cd esp8266-ats/dweet_ats
$ make
ATS user/user_main.dats
CC build/user/user_main_dats.c
In file included from build/user/user_main_dats.c:15:0:
build/user/user_main_dats.c: In function
'ATSLIB_056_prelude__string1_append__5__1':
/home/kiwamu/src/ATS-Postiats/ccomp/runtime/pats_ccomp_instrset.h:266:35:
error: assignment makes pointer from integer without a cast [-Werror]
#define ATSINSmove(tmp, val) (tmp = val)
^
build/user/user_main_dats.c:873:1: note: in expansion of macro 'ATSINSmove'
ATSINSmove(tmp19__1, atspre_malloc_gc(tmp20__1)) ;
^
cc1: all warnings being treated as errors
../Makefile.common:146: recipe for target 'build/user/user_main_dats.o' failed
make: *** [build/user/user_main_dats.o] Error 1
rm build/user/user_main_dats.c
```
What's wrong?
On POSIX, following code is available:
```
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"
%{^
void atsruntime_mfree_undef (void *ptr) {
free(ptr);
return;
}
void *atsruntime_malloc_undef (size_t bsz) {
return malloc(bsz);
}
%}
implement main0 () = {
val json_data = string0_append ("{\"temperature\": ", "")
val () = println! json_data
val () = free json_data
}
```
Thanks,
--
Kiwamu Okabe at METASEPI DESIGN