C for scripting
Ever imagined of using C as a scripting language? Install TCC. Write a simple C program:
// add.c #include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { /* No error checking. */ int a = atoi(argv[1]); int b = atoi(argv[2]); printf("%d\n", (a + b)); return 0; }
Add this line to the top of the file:
#!tcc -run
Mark the file as executable:
$ chmod +x add.c
Run it:
$ ./add.c 10 20 30
The TCC executable is only 100Kb in size, but it can compile the Linux kernel! An ideal use for TCC is as an embedded compiler to dynamically generate executables.