Ch is a superset of C language. It parses and executes C code directly without intermediate code or byte code. It does not distinguish interpreted code from compiled C/C++ code. The new Ch 4.0 is the most complete C interpreter in existence and is embeddable in other programs and hardware.
Here is the most tiny, just for fun 😉
( The second and third lines are just one line )
#!/bin/sh
tail +3 $0 >/tmp/cs.$$.c && gcc -Wall -o /tmp/cs.$$ tmp/cs.$$.c && /tmp/cs.$$ $*; rm -f /tmp/cs.$$*; exit
#include<stdio.h>
int main(int argc, char** argv) {
if (argc <= 1)
puts(“Hello Word!”);
else
printf(“Hello %s!
“, argv[1]);
return 0;
}
tmp/cs.$$.c should be /tmp/cs.$$.c
PS: it would be good to be able to visualize our posts
yes “I will use mktemp” :oD
Hmm…I’ve used “tcc” a bit for some things.
It also has the ability to “interpret” c code. Actually it compiles and executes on the fly.
http://fabrice.bellard.free.fr/tcc/
Right now they’re got the protest page up…so you have to go here:
http://fabrice.bellard.free.fr/tcc/index.org.html
I’m not sure how cross platform it is though.
Why did they need to execute C? What was his crime?
Nice to hear about other small CCs Ch,tcc etc. I’ve been plowing through the lcc code so I can’t help but wonder whats in the other compilers although lcc will keep me busy for awhile.
I just wanted to point out that there are other systems for doing similar things. In particular, http://llvm.cs.uiuc.edu“>LLVM
This is not a direct competitor, because it does go through a bytecode representation, but for a lot of things, it is just as useful. <p>
-Chris
#!/bin/sh
tail +3 $0 >/tmp/cs.$$.c && gcc -Wall -o /tmp/cs.$$ tmp/cs.$$.c && /tmp/cs.$$ $*; rm -f /tmp/cs.$$*; exit
It looks like you could drop the compile and link cycle with ch. Maybe even add a key code to vim so you could test your c code on the fly.
There has been alot of stuff posted here lately that wants my personal information. What gives?
I notice in the license they talk about getting it in source form, but can anyone find out how to do this one their site? Also, does this apply to the Pro version or just the Standard?
shame on you for bypassing that page
Does it have any use?
Imagine having a little virtual machine, like bochs or somesuch.
Imagine being able to test the latest kernel on the virtual machine without having to wait for the compile?
Then there’s this thing in the back of my mind that says, “hey, it runs c, it’ll run the python interpreter…”, even though I know that it is useless. An interpreter running on an interpreter. What more fun could you have with the thing?