Java binding version of TINYCC Tcc4java

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.