Last active
January 9, 2023 20:25
-
-
Save bartman/8b3bcc0a2431678d64d2bfb4849c02a5 to your computer and use it in GitHub Desktop.
run C file as a script, complied with any compiler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#if 0 | |
set -e | |
src=$0 | |
tmp=/tmp/$$.cpp | |
exe=/tmp/$$ | |
sed -e 1d < $src > $tmp | |
trap "rm -f $tmp $exe" EXIT | |
( set -x ; g++ -o $exe $tmp ) | |
$exe "$@" | |
exit $? | |
#endif | |
#include <stdio.h> | |
int main() | |
{ | |
printf("hello word\n"); | |
} |
Author
bartman
commented
Jan 9, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment