title: Do macros make the code more readable?
body: <p>I had a debate about macros and their readability.
  I think that in some cases using macros can make the code shorter, more comprehensible and less tiring to read.</p>
  
  <p>For example:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  #define EXIT_ON_FAILURE(s) if(s != 0) {std::cout &lt;&lt; "Exited on line " &lt;&lt; __LINE__ &lt;&lt; std::endl; exit(1);}
  
  inline void exitOnFailure(int s, int lineNum) {
      if (s != 0) {
          std::cout &lt;&lt; "Exited on line " &lt;&lt; lineNum &lt;&lt; std::endl; 
          exit(1);
      }
  }
  
  int foo() {
      return 1;
  }
  
  int bar(int a, int b, int c) {
      return 0;
  }
  
  int main() {
      // first option
      if (foo() != 0) {
          std::cout &lt;&lt; "Exited on line " &lt;&lt; __LINE__ &lt;&lt; std::endl;
          exit(1);    
      }
      if (bar(1, 2, 3) != 0) {
          std::cout &lt;&lt; "Exited on line " &lt;&lt; __LINE__ &lt;&lt; std::endl;
          exit(1);    
      }
  
      // second option
      EXIT_ON_FAILURE(foo());
      EXIT_ON_FAILURE(bar(1, 2, 3));
  
      // third option
      exitOnFailure(foo(), __LINE__);
      exitOnFailure(bar(1, 2, 3), __LINE__);
  
      return 0;
  }
  </code></pre>
  
  <p>I prefer the second option here, since it's short and compact and the caps lock text is just clearer and easier to read than camel case.</p>
  
  <p>Is there anything wrong with this method, particularly in C++, or is it just bad (but acceptable) style?</p>