#if 0 hacks
ネタ元: d:id:Seasons:20090504:1241390314
さっそく試してみた。たしかに楽しい。
$ cat << EOF > a.c > #if 0 > src=\$0; dst=\${src%.*}; gcc -o \$dst \$src && ./\$dst; exit > #endif > #include <stdio.h> > int main(void) { return puts("hello, world."), 0; } > EOF $ sh a.c hello, world.
まあでも、このハックを使わなくても C/C++ ソースファイルなら Makefile なしの make で通せるけどね…。
$ cat a.c #if 0 src=$0; dst=${src%.*}; gcc -o $dst $src && ./$dst; exit #endif #include <stdio.h> int main(void) { return puts("hello, world."), 0; } $ make a cc a.c -o a $ ./a hello, world.