* Jonathan Wakely via Gcc:
> Here's a complete example:
>
> #!/bin/sh
> set -e
> out=$(mktemp /tmp/a.out.XXXXXX)
> sed 1,5d "$0" | gcc -x c - -o "$out"
> exec "$out"
>
> #include <stdio.h>
> int main()
> {
> puts("Hello, world");
> return 0;
> }
Or this, with accurate locations for diagnostics and argument
handling:
#!/bin/sh
set -e
out=$(mktemp /tmp/a.out.XXXXXX)
(echo "#line 6 \"$0\""; sed 1,5d "$0") | gcc -x c - -o "$out"
exec "$out" "$@"
#include <stdio.h>
int main()
{
puts("Hello, world");
return 0;
}
Still it would be a nice touch if we could do
#!/usr/bin/gcc -f
#include <stdio.h>
int main()
{
puts("Hello, world");
return 0;
}
instead.