title: Is it better to use `#ifdef` or inheritance for cross-compiling?
body: <p>To follow from my <a href="https://stackoverflow.com/questions/1990032/using-c-how-do-i-correctly-inherit-from-the-same-base-class-twice">previous question about virtual and multiple inheritance</a> (in a cross platform scenario) - after reading some answers, it has occurred to me that I could simplify my model by keeping the server and client classes, and replacing the platform specific classes with #ifdefs (which is what I was going to do originally).</p>
  <p>Will using this code be simpler? It'd mean there'd be less files at least! The downside is that it creates a somewhat &quot;ugly&quot; and slightly harder to read <code>Foobar</code> class since there's <code>#ifdefs</code> all over the place. Note that our Unix Foobar source code will never be passed to the compiler, so this has the same effect as <code>#ifdef</code> (since we'd also use <code>#ifdef</code> to decide what platform specific class to call).</p>
  <pre><code>class Foobar {
  public:
    int someData;
  
  #if WINDOWS
    void someWinFunc1();
    void someWinFunc2();
  #elif UNIX
    void someUnixFunc1();
    void someUnixFunc2();
  #endif
  
    void crossPlatformFunc();
  };
  
  class FoobarClient : public Foobar;
  class FoobarServer : public Foobar;
  </code></pre>
  <p>Note: Some stuff (ctor, etc) left out for a simpler example.</p>
  <h2>Update:</h2>
  <p>For those who want to read more into the background of this issue, I really suggest skimming over the appropriate <a href="http://groups.google.com/group/synergy-plus-dev/browse_thread/thread/481529a065d3362a" rel="nofollow noreferrer">mailing list thread</a>. Thing start to get interesting around the 3rd post. Also there is a <a href="http://code.google.com/p/synergy-plus/source/detail?r=344" rel="nofollow noreferrer">related code commit</a> with which you can see the real life code in question here.</p>