Skip to content

Winsock2.h problem and fix #387

Closed
Closed
@nkindt

Description

@nkindt

Just including the header won't always work on Windows, resulting in tons of errors of the kind (around 1810 errors in my case):

Error C2446 '!=': no conversion from 'long' to 'int (__cdecl *)(void)'
Error C2027 use of undefined type 'fd_set'
Error C2375 'WSAAsyncGetServByName': redefinition; different linkage
...

The fix is to include Winsock2.h first (before Windows.h) or include Windows.h by defining WIN32_LEAN_AND_MEAN beforehand:
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

Might be good to mention this somewhere since otherwise it's not as easy as simply including the header and get going because of this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions