什么是 TCC? TinyCC(又名TCC)是一个小而超快速的C编译器。不像其他的C编译器, 它是为了自我依靠:你不需要一个外部汇编器或连接器。 TinyCC主页:http://bellard.org/tcc/. What is TCC4Java? 1. Supported os: Windows x86/x64 Linux x86/x64/arm Mac OS X Debian kFreeBSD x86/x64 FreeBSD x86/x64 NetBSD x86/x64 DragonFlyBSD x86/x64 Solaris x86 TCC4Java has been tested under the following os: 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 are also supported) NetBSD 6.1.4 x86/x64 DragonFlyBSD 3.6.2 x86/x64 Solaris 10/11 x86 4. Supported jdk: jdk 1.5 or later 5. TCC4Java is released under Apache License 2.0. 6. TCC4Java's homepage is https://github.com/wangzhengbo/TCC4Java, you can download the compiled jar from https://sourceforge.net/projects/tcc4java.
简单的例子:
</div>
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(); } }