3 ms·
It's much simpler: $ cat >test.c //usr/bin/gcc "$0" -o /tmp/out.exe || exit; exec /tmp/out.exe "$@" #include <stdio.h> void main(int argc, char
by v_lisivka 9y ago
It's much simpler:
$ cat >test.c
//usr/bin/gcc "$0" -o /tmp/out.exe || exit; exec /tmp/out.exe "$@"
#include <stdio.h>
void main(int argc, char **argv) {
printf("Hello, world!");
}
^D
$ chmod a+x test.c
$ ./test.c
Hello, world!
- modeless 9y agoEven shorter, works unmodified with both C and C++, and doesn't recompile unless necessary: //usr/bin/make -s "${0%.*}"&&exec "${0%.*}" "$@";exit