[bf1942] Programming and server porting

ScratchMonkey ScratchMonkey at SewingWitch.com
Sun Feb 9 02:49:00 EST 2003


--On Sunday, February 09, 2003 12:07 AM -0700 Scott Brooks <blaze at fragz.ca> 
wrote:

> One thing nobody has mentioned yet is you will probably need to learn
> the windows equivalents to sockets, threads, and syncronization so when
> you are trying to port something you will know what's going on.

And when you do, wrap the platform-specific code in wrappers so that you 
can keep all the platform-specific code in one place. The cost of a wrapper 
is small compared to the cost of the system call it wraps.

#if defined(__WINDOWS__)
int MySocket(...) { return WindowsSocketEquivalent(...); }
#elif defined(__LINUX__)
int MySocket(...) { return socket(...); }
#endif

Ideally you put all the Windows-specific code in one file, Linux in 
another, and just link the one for the OS you're using.

I cringe when I see the way M$ tools like to litter every source file with 
#include "afx.h" and #include <windows.h>. Nah, it couldn't be to make it 
hard for you to support a non-M$ platform, right? ;)



More information about the Bf1942 mailing list