Skip to content

Instantly share code, notes, and snippets.

@peteb
Created July 22, 2011 19:05
Show Gist options
  • Save peteb/1100155 to your computer and use it in GitHub Desktop.
Save peteb/1100155 to your computer and use it in GitHub Desktop.
Embedding C in Anita
<%
#include <stdio.h>
GLOBAL_SYM(add);
%>
val my_printer = fun(a) => <%|a|
printf("--> %p\n", a);
//RET(string_object("en katt"));
object_t params = array_object(1);
array_set_elementC(params, 0, int_object(10));
RET(CALL_METHOD(a, add, params));
%>
val main = fun() => {
<%
// Really cool stuff
printf("Hello from C!\n");
%>;
<% printf("good day\n"); %>.to_s.puts;
my_printer(123).to_s.puts;
# TODO: colorize <% and %>
<%
THROW(string_object("something went wrong"));
%>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment