Hacker News new | ask | show | jobs
by godelski 3203 days ago
Curly brace expansion is one of the most useful and overlooked topic in these kind of posts. And I'm always surprised it isn't mentioned with compiling.

g++ -o foo{,.cpp}

2 comments

Worth noting that for the particular case you've cited, you can just use make, even without a makefile:

  ~ cat test.cpp 
  #include <iostream>
  
  using namespace std;
  
  int main()
  {
      cout << "hi\n";
      return 0;
  }
  ~ stat Makefile
  stat: cannot stat 'Makefile': No such file or directory
  ~ 1 make test
  g++     test.cpp   -o test
  ~ ./test
  hi
Well you learn something every day. That's pretty awesome! Is there an easy way to add options? Like -O2
yeah, reading make man, and also http://nullprogram.com/blog/2017/08/20/
also, useful to know - zsh supports tab-completion for curly brace expansion.