Comment

Comment by d99kris

I do something similar (but less portable and more verbose) in C++ sometimes when I want to prototype something. My boilerplate is something like this:

  #if 0
  TMP=$(mktemp -d);
  c++ -std=c++11 -o ${TMP}/a.out ${0} && ${TMP}/a.out ${@:1}; RV=${?};
  rm -rf ${TMP};
  exit ${RV};
  #endif
    
  #include <iostream>
    
  int main()
  {
    std::cout << "Hello, world!\n";
  }
(the trailing semi-colons in the script part is to make my editor indent the C++ code properly)
parent d99kris 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton