3 ms·
I do something similar when working on single-file programs, but without any external dependencies, by making the file both a valid shell script (for my shell)
by mikeash 12y ago
I do something similar when working on single-file programs, but without any external dependencies, by making the file both a valid shell script (for my shell) and a valid C program. Here's an example in Swift, although the same idea works for C too:
https://gist.github.com/mikeash/70d74f7b7745cf6fbd3f https://gist.github.com/mikeash/70d74f7b7745cf6fbd3f
- lambda 12y agoThat's pretty complicated; you could just do: //usr/bin/env swift $0 "$@"; exit $? println("helloo")
- mikeash 12y agoMy approach avoids recompiling the program every time you run it, and it also makes it much easier to debug crashes. At least when I was doing this, running `swift` directly produced really bad crash info when things went wrong.