Dear all,

I have written the following program using Visual Studio Express 2013 to figure out my problem:


#pragma comment (lib, "ws2_32.lib")

#include <stdio.h>
#include <winsock2.h>

int main (int argc, char *argv[])
{
WSADATA wsa;
if (1==2) WSAStartup(MAKEWORD(2,0),&wsa);
} // main



The programm crashes after start "Unhandled exception at 0x5DF1E71A in 3D_20.exe: 0xC0000005: Access violation writing location 0x000A0FF8."

The problem is the code WSAStartup(MAKEWORD(2,0),&wsa);
You see that the (1==2) never will be true so WSAStartup will not be excuted, but the presence of this piece of code makes the program crash.
Useless to say that compiling give no errors.
If I omit the critical line, the program runs withpout problems.

If I insert printf... or whatever after main and before WSAStartup this will not executed! The problem is the pure existence of WSAStartup in the code!

This is very strange to me. Any ideas?

Best Regards,
Andreas