3 ms·
Nice. Mine is short and sweet -- just one line. Dunno whether it is better. I've had to put it in gdocs because HN fouls up the asters. https://docs.google.
by emmelaich 9y ago
Nice. Mine is short and sweet -- just one line. Dunno whether it is better. I've had to put it in gdocs because HN fouls up the asters.
https://docs.google.com/document/d/1sBzur57FeLqzgcoGMz8jwOgMQmt5TxolACgTMyM6qkg/edit?usp=sharing https://docs.google.com/document/d/1sBzur57FeLqzgcoGMz8jwOgM...
- modeless 9y agoHa, I'd seen the 3 line #if 0 version but not this! If you don't care about the fact that execve won't work, then this is pretty great.
- emmelaich 9y ago(execve)... Challenge accepted. :-) Might be just a matter of a shebang at the beginning and an 'exec' before the final $p.
- modeless 9y agoYeah, a shebang is required, and unfortunately it isn't valid C so you can no longer feed the file directly to the compiler. I just figured out how to whittle it down to 2 lines though! Thanks for the // idea. Here it is in both shebang (2 line) and non-shebang (1 line) versions: https://gist.github.com/jdarpinian/1952a58b823222627cc1a8b83a7aa4e2 https://gist.github.com/jdarpinian/1952a58b823222627cc1a8b83...
- emmelaich 9y agoThanks, good stuff. dolmen/Olivier's followup is good too. I now remember why I used the complicated expr command and make; it's to ensure it works with C and C++. And any language that happens to accept // as a comment and is supported by "make". (note that no actual Makefile is required)
- modeless 9y agoThat is a cool feature! It's a bit annoying to have separate versions for C and C++.