Sunday, September 18, 2011

Innendrin - A vala binding for TinyCC

Sunday night, best time to write some lines.
TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike other C compilers, it is meant to be self-relying: you do not need an external assembler or linker because TCC does that for you. 
This vapi allows to call tcc from within vala, a small example is given below. I used it in conjunction with genetic programming.

using TCC;
void main(string[] args)
	State s = new State();
	s.add_include_path (args[1] + "/include");
	s.add_include_path ("/usr/include/");
	s.set_lib_path (args[1]);
	s.compile_string  ("""
#include <tcclib.h>
void main(int argc, char** argv) {
	printf("Hello %s\n", argv[0]);
"""); ({"world."});

No comments:

Post a Comment