Run C or C++ file as a script

So this is probably a long shot, but is there any way to run a C or C++ file as a script? I tried:

#!/usr/bin/gcc main.c -o main; ./main

int main(){ return 0; }

But it says:

./main.c:1:2: error: invalid preprocessing directive #!


For C, you may have a look at tcc, the Tiny C Compiler. Running C code as a script is one of its possible uses.

Leave a Reply

Your email address will not be published. Required fields are marked *