Skip to content

Instantly share code, notes, and snippets.

@xspager
Last active August 9, 2016 07:28
Show Gist options
  • Save xspager/43b9e3d3b4b926abe556c9e2f444db5e to your computer and use it in GitHub Desktop.
Save xspager/43b9e3d3b4b926abe556c9e2f444db5e to your computer and use it in GitHub Desktop.
local target = terralib.newtarget {
--Triple = "x86_64-apple-darwin";
Triple = "x86_64-pc-linux";
-- CPU = "";
Features = "";
}
local C = terralib.includecstring([[
#include <stdio.h>
typedef struct {
int a;
int b;
} foo;
]], {}, target)
terra main()
var v: C.foo
v.a = 1
v.b = 2
C.printf("%d %d\n", v.a, v.b)
end
terralib.saveobj("target", {main=main}, {}, target)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment