1. 16
  1.  

  2. 4

    To use actual C as a scripting language, check out TCC!

    TCC can also be used to make C scripts, i.e. pieces of C source that you run as a Perl or Python script. Compilation is so fast that your script will be as fast as if it was an executable. You just need to add #!/usr/local/bin/tcc -run at the start of your C source:

    #!/usr/local/bin/tcc -run
    #include <stdio.h>
    
    int main() 
    {
        printf("Hello World\n");
        return 0;
    }
    
    1. 2

      The output of compiling Little is tcl code. See http://www.little-lang.org/why.html

      1. 1

        I’m late, but GCC works fine too, works for CGI nicely, here are two one-liners:

        » cat demo.sh

        #!/opt/misc/chax

        void main(void){printf("Content-Type: text/plain\n\n");printf("Hello World!\n");}

        » cat /opt/misc/chax

        #!/bin/sh

        (TMPO=`mktemp`;sed -n '2,$p' "$@"|gcc 2>/dev/null -std=gnu99 -pipe -O2 -x c -o $TMPO - &&$TMPO 2>/dev/null;rm -f $TMPO)

      2. 2

        Is there a major mode for this yet?

        1. 3

          Actually c-mode works pretty well.