summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.html2
-rw-r--r--README.md2
-rw-r--r--foreign.c8
3 files changed, 8 insertions, 4 deletions
diff --git a/README.html b/README.html
index 2bf99bb..f00bf27 100644
--- a/README.html
+++ b/README.html
@@ -48,7 +48,7 @@ it is nearly as fast in theory.</p>
<p>Most of the source code for the <code>toc</code> compiler is licensed under the GNU General Public License, version 3. See <code>LICENSE</code> for more information.</p>
-<p><code>toc</code> is written in C, for speed and portability. It has no dependencies, other than the C runtime library.</p>
+<p><code>toc</code> is written in C, for speed and portability. It has no dependencies, other than the C runtime library. If you want to be able to call external C functions at compile time, however, you will need <code>libffcall</code> and <code>libdl</code> (so this is only currently supported on Unix-y systems).</p>
<h4>Build system</h4>
diff --git a/README.md b/README.md
index 22ca0cf..acc64ba 100644
--- a/README.md
+++ b/README.md
@@ -45,7 +45,7 @@ On other systems, you can just compile main.c with a C compiler. `toc` uses seve
Most of the source code for the `toc` compiler is licensed under the GNU General Public License, version 3. See `LICENSE` for more information.
-`toc` is written in C, for speed and portability. It has no dependencies, other than the C runtime library.
+`toc` is written in C, for speed and portability. It has no dependencies, other than the C runtime library. If you want to be able to call external C functions at compile time, however, you will need `libffcall` and `libdl` (so this is only currently supported on Unix-y systems).
#### Build system
`toc` is set up as a unity build, meaning that there is only one translation unit. So, `main.c` `#include`s `toc.c`, which `#include`s all of `toc`'s files.
diff --git a/foreign.c b/foreign.c
index cad605c..8a1b7b6 100644
--- a/foreign.c
+++ b/foreign.c
@@ -165,6 +165,10 @@ static bool arg_list_add(av_alist *arg_list, Value *val, Type *type, Location wh
case TYPE_PTR:
av_ptr(*arg_list, void *, val->ptr);
break;
+ case TYPE_FN:
+ warn_print(where, "Passing toc function pointer to foreign function. This will not work if the function expects a C-style function pointer.");
+ av_ptr(*arg_list, FnExpr *, val->fn);
+ break;
case TYPE_BUILTIN:
switch (type->builtin) {
case BUILTIN_I8:
@@ -261,8 +265,8 @@ static bool foreign_call(FnExpr *fn, Type *fn_type, Value *args, Location call_w
return true;
}
#else
-static bool foreign_call(FnExpr *fn, Type *fn_type, Value *args, Location call_where) {
- (void)fn; (void)fn_type; (void)args;
+static bool foreign_call(FnExpr *fn, Type *fn_type, Value *args, Location call_where, Value *ret) {
+ (void)fn; (void)fn_type; (void)args; (void)ret;
err_print(call_where, "You have not compiled toc with compile time foreign function support.");
return false;
}