Including WinSock2.h in 4.12.5 plugin causes compile error

Creating a blank C++ project, then creating a blank Blueprint Function Library plugin, then adding to my plugin precompiled header, will cause Unreal Engine to break compile, because WinSock2.h defines PF_MAX, which is also used as an enum name in Unreal’s “PixelFormat.h”

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

#include "WinSockPlugin.h"

// You should place include statements to your module's private header files here.  You only need to
// add includes for headers that are used in most of your module's source files though.
#include "AllowWindowsPlatformTypes.h"
#include <winsock2.h>
#include "HideWindowsPlatformTypes.h"

Generates:

2>------ Build started: Project: MyProject2, Configuration: Development_Editor x64 ------
2>  Performing 3 actions (4 in parallel)
2>  Module.WinSockPlugin.cpp
2>  WinSockPlugin.generated.cpp
2>C:\Program Files (x86)\Epic Games\4.12\Engine\Source\Runtime/Engine/Public/PixelFormat.h(65): error C2059: syntax error: 'constant'
2>C:\Program Files (x86)\Epic Games\4.12\Engine\Source\Runtime/Engine/Public/PixelFormat.h(65): error C3805: 'constant': unexpected token, expected either '}' or a ','
2>C:\Program Files (x86)\Epic Games\4.12\Engine\Source\Runtime/Engine/Public/PixelFormat.h(65): error C2059: syntax error: 'constant'
2>C:\Program Files (x86)\Epic Games\4.12\Engine\Source\Runtime/Engine/Public/PixelFormat.h(65): error C3805: 'constant': unexpected token, expected either '}' or a ','
2>ERROR : UBT error : Failed to produce item: C:\Users\jwatte\Documents\Unreal Projects\MyProject2\Plugins\WinSockPlugin\Binaries\Win64\UE4Editor-WinSockPlugin.pdb
2>  Total build time: 21.63 seconds

A work-around is to undefined PF_MAX after including WInSock2.h but that’s bad if I actually need the name of this symbol. The main problem is that Unreal defines symbols that clash with Windows.

To reproduce, see the screen shots.

(Edit: the forum swallowed the header file names enclosed in angle brackets. And I had a typo in the subject.)

Can I at least get this filed as a bug?