title: How to stub a function in C++ that has a return type?
body: <p>Assuming I want to stub a function in case I am compiling for project2, example:</p>
  
  <pre><code>#ifdef PROJECT1
  int func(int x) {x=1;return x;}
  #else
  int func(int x) {}
  #endif
  </code></pre>
  
  <p>This wont work as the compiler will complain that the function doesnt return an int.</p>
  
  <p>But I really just want to stub the function, I basically, want to have it nulled whenever it is called.</p>
  
  <p>To fix this I basically have to change the code to:</p>
  
  <pre><code>#ifdef PROJECT1
  int func(int x) {x=1;return x;}
  #else
  int func(int x) {return (int)0;}
  #endif
  </code></pre>
  
  <p>Is there a way to better handle this?</p>