<div dir="ltr">One approach that I've seen for this in games where virtual function calls are an unhappy thing is a pattern where the inheritance appears to be inverted:<div><br></div><div>In this case, you'd have each platform class in their own files and directory structure:</div>

<div><br></div><div>    class HostThreadMacOSX { ... };</div><div><br></div><div>    class HostThreadWindows { ... };</div><div><br></div><div>Then, you'd have a single HostThread.h that looked roughly like:</div><div>

<br></div><div><div>    if (__WIN32__)</div><div>    #include "threading/windows/HostThreadWindows.h"</div><div><br></div><div>    namespace lldb</div><div>    {</div><div>    class HostThread : public Windows::HostThreadWindows</div>

<div>    { </div><div>    };<br></div><div>    }</div><div>    #elif __APPLE__</div><div>    #include "threading/macosx/HostThreadMacOSX.h"</div><div>    namespace lldb</div><div>    {</div><div>    class HostThread : public MacOSX::HostThreadMacOSX</div>

<div>    {</div><div>    };<br></div><div>    }</div><div>    #else</div><div>    #error "lldb::HostThread not implemented on this platform!"</div><div>    #endif</div></div><div><br></div><div>Now, all of the code can reference HostThread, there are no virtual calls, and each platform can invoke platform-specific behavior with ease.</div>

<div><br></div><div>It has some downsides, like the exact interface of what is required isn't as clear (since there's no "interface" class), but I've had good luck with this structure in the past.</div>

<div><br></div><div>Hope this is interesting / useful!</div><div><br></div><div> - Bruce</div><div><br></div></div>