Skip to content

Instantly share code, notes, and snippets.

@mohiji
Created September 8, 2011 16:55
Show Gist options
  • Save mohiji/1203900 to your computer and use it in GitHub Desktop.
Save mohiji/1203900 to your computer and use it in GitHub Desktop.
Pre-processor abuse
#ifdef WIN32
WSADATA g_wsadata;
#define StartSocketLib WSAStartup( MAKEWORD(2, 2), &g_wsadata);
#define CloseSocketLib WSACleanup();
#else
#define StartSocketLib {}
#define CloseSocketLib {}
#endif
/* Used later on like this: */
void main() {
StartSocketLib;
// do networky stuff
CloseSocketLib;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment