--
You received this message because you are subscribed to a topic in the Google Groups "ats-lang-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ats-lang-users/DjbmPoC6mjM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
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/CALn1vHGkJhD_m6YzVKDwLfOPKGjgyOo%3DLLTRPAP%2BBRi_DMJbEw%40mail.gmail.com.
void remember_this(char *name, char *meaning);
char *what_was(char *name); /* returns meaning */
extern fun remember_this: (string, string) -> void = "ext#"
extern fun what_was: string -> string = "ext#"
implement remember_this(k, v) = ...
val fruits = $list{string}("apples", "pears", "tomatoes (yes really)")
val () = println!("the previous line builds the list at runtime!")
extern fn c_main: (int, !argv) -> int = "ext#"
implement main(argc, argv) = (
// all those dynload functions have already been called at this point
// now do your own stuff
// then call this until the Borg takes it as well:
c_main(argc, argv)
)
#include <stdio.h>
#include <stdlib.h>
extern int think_deeply(void);
void setn (int *n) {
*n = 21;
}
int main(void) {
int ans = think_deeply();
printf("the answer is: %d\n", ans);
return 0;
}
#include "share/atspre_staload.hats"
#define ATS_DYNLOADFLAG 0
extern fun think_deeply: () -> int = "ext#"
extern fun setn(&int? >> int): void = "ext#"
implement think_deeply() = n * 2 where {
var n: int
val () = setn(n)
}
$ ls
deepthought.dats main.c
$ patscc -c main.c
$ patscc -c deepthought.dats
$ patscc main.o deepthought_dats.o -o think
$ ./think
the answer is: 42
$
clang: warning: argument unused during compilation: '-L/usr/local/Cellar/ats2-postiats/0.3.10/lib/ats2-postiats-0.3.9/ccomp/atslib/lib' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L/usr/local/Cellar/ats2-postiats/0.3.10/lib/ats2-postiats-0.3.9/ccomp/atslib/lib64' [-Wunused-command-line-argument]
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
"/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -dynamic -arch x86_64 -macosx_version_min 10.13.0 -o think -L/usr/local/Cellar/ats2-postiats/0.3.10/lib/ats2-postiats-0.3.9/ccomp/atslib/lib -L/usr/local/Cellar/ats2-postiats/0.3.10/lib/ats2-postiats-0.3.9/ccomp/atslib/lib64 main.o deepthought_dats.o -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/lib/darwin/libclang_rt.osx.a
ld: warning: directory not found for option '-L/usr/local/Cellar/ats2-postiats/0.3.10/lib/ats2-postiats-0.3.9/ccomp/atslib/lib64'
Undefined symbols for architecture x86_64:
"_setn", referenced from:
_think_deeply in deepthought_dats.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
--
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 ats-lang-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
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/b9d77184-9000-4350-9f9f-b0103f7d83f0%40googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "ats-lang-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ats-lang-users/DjbmPoC6mjM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
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/b9d77184-9000-4350-9f9f-b0103f7d83f0%40googlegroups.com.
I tried the deepthought example, (I use homebrew to install the latest version of ATS) but error occured when binding the two object files.These are the warning messages showed when compiling both the C and ATS files:clang: warning: argument unused during compilation: '-L/usr/local/Cellar/ats2-postiats/0.3.10/lib/ats2-postiats-0.3.9/ccomp/atslib/lib' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L/usr/local/Cellar/ats2-postiats/0.3.10/lib/ats2-postiats-0.3.9/ccomp/atslib/lib64' [-Wunused-command-line-argument]
# brew link --overwrite ats2-postiatsWarning: Already linked: /usr/local/Cellar/ats2-postiats/0.3.10To relink: brew unlink ats2-postiats && brew link ats2-postiats# patscc -c main.c
clang: warning: argument unused during compilation: '-L/usr/local/Cellar/ats2-postiats/0.3.10/lib/ats2-postiats-0.3.9/ccomp/atslib/lib' [-Wunused-command-line-argument]clang: warning: argument unused during compilation: '-L/usr/local/Cellar/ats2-postiats/0.3.10/lib/ats2-postiats-0.3.9/ccomp/atslib/lib64' [-Wunused-command-line-argument]
# patscc -c deepthought.dats
clang: warning: argument unused during compilation: '-L/usr/local/Cellar/ats2-postiats/0.3.10/lib/ats2-postiats-0.3.9/ccomp/atslib/lib' [-Wunused-command-line-argument]clang: warning: argument unused during compilation: '-L/usr/local/Cellar/ats2-postiats/0.3.10/lib/ats2-postiats-0.3.9/ccomp/atslib/lib64' [-Wunused-command-line-argument]
# patscc main.o deepthought_dats.o -o think
ld: warning: directory not found for option '-L/usr/local/Cellar/ats2-postiats/0.3.10/lib/ats2-postiats-0.3.9/ccomp/atslib/lib64'
# ./thinkthe answer is: 42
# patscc deepthought_dats.o main.o -o think
ld: warning: directory not found for option '-L/usr/local/Cellar/ats2-postiats/0.3.10/lib/ats2-postiats-0.3.9/ccomp/atslib/lib64'Undefined symbols for architecture x86_64:
"_setx", referenced from:
_think_deeply in deepthought_dats.old: symbol(s) not found for architecture x86_64clang: error: linker command failed with exit code 1 (use -v to see invocation)
I tried the deepthought example, (I use homebrew to install the latest version of ATS) but error occured when binding the two object files.
In the section http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/x2080.html, I missed if it is also possible to define a value in ATS and then access it from C. Is it possible?
#include "share/atspre_staload.hats"
extern fn putvars(): void = "ext#"
%{
int n[1];
int *m;
void putvars() { printf("n is: %d\nm is: %d\n", *n, *m); }
%}
val myval = 42
var myvar = myval
extvar "m" = addr@myvar
val () = myvar := myvar + 1
implement main0() = (
$UNSAFE.ptr0_set<int>($extval(ptr, "n"), myval);
putvars();
)
--
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 ats-lang-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
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/c5a83b81-e788-4342-ba48-f7a40bd83e63%40googlegroups.com.