Tcc4java is a Java binding for TINYCC (also known as TCC, a magical C compiler), allowing Java to support the use of C as a scripting language.
Tcc4java supports the following operating systems:
Windows x86/x64
Linux X86/x64/arm
Mac OS X
Debian KFreeBSD x86/x64
FreeBSD x86/x64
NetBSD x86/x64
Dragonflybsd x86/x64
Tested in the following systems:
Windows XP SP3 x86
Windows 7 SP1 x86
Ubuntu 12.04 x86/x64
Debian Wheezy Raspbian 2014-01-07
Mac OS X 10.7
Debian KFreeBSD 7.5.0 x86/x64
FreeBSD 9.0 x86/x64 (the FreeBSD based OS such as GHOSTBSD, Pc-bsd, Archbsd, Midnightbsd is also supported)
NetBSD 6.1.4 x86/x64
Dragonflybsd 3.6.2 x86/x64
[url=http://www.huiyi8.com/jiaoben/] Css[/url]
A simple example:
Import java.io.IOException;
Import Cn.com.tcc.State;
Import Cn.com.tcc.TCC;
public class HELLOTCC {
public static void Main (string[] args) throws IOException {
Tcc.init ("./tcc/");
state state = new State ();
state.compilestring ("int sum (int a, int b) {return a + B;} \ n "
+ "int main (int argc, char* argv[]) {printf (\" sum (%d,%d) =%d\\n\ ", Atoi (Argv[1]), Atoi (argv[2]), SUM (atoi (argv[1)), atoi (argv[2])); return 0;} ");
State.run ("", 2, 3);
State.delete ();
}
}
Tcc.init () initializes the TCC, which is the directory containing the TCC Dynamic link library and header files.
State.compilestring () takes a string containing a C program as an argument, compiles it, State.run () runs the compiled program, and passes parameters 2 and 3 to calculate their and. The program output is:
SUM (2, 3) = 5
For more examples, see examples and test in http://www.huiyi8.com/jiaoben/.
Java binding version of TINYCC Tcc4java