Bug 71405 - winsock.h header gymnastics don't work on MinGW
Summary: winsock.h header gymnastics don't work on MinGW
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: All Windows (All)
: medium normal
Assignee: Havoc Pennington
QA Contact:
Whiteboard: basically review+, needs Windows ack
Keywords: patch
Depends on:
Reported: 2013-11-08 22:20 UTC by Matt Fischer
Modified: 2014-01-06 16:31 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:

Define WIN32_LEAN_AND_MEAN in Windows port (1.18 KB, text/plain)
2013-11-08 22:20 UTC, Matt Fischer

Description Matt Fischer 2013-11-08 22:20:43 UTC
Created attachment 88911 [details]
Define WIN32_LEAN_AND_MEAN in Windows port

The windows sysdep file is using a somewhat dodgy mechanism to prevent windows.h from automatically including winsock.h--it's trying to define the header guard macro for winsock.h, to trick the compiler into not including it.  This is causing me problems on MinGW because its version of winsock.h uses a different guard macro name.

From reading around online, it appears that defining WIN32_LEAN_AND_MEAN will also serve to prevent winsock.h from being included.  That's less brittle, since it's actually a defined piece of windows.h's API, instead of an implementation detail of one of its headers.  Replacing the header guard definition with that seems to work correctly for me on MinGW32 4.0.3, although I am not able to test it with any other Windows toolchain at the moment.

Is this an OK change to make, or is there some other reason that the guard macro approach had been used?
Comment 1 Simon McVittie 2013-11-11 12:23:54 UTC
Looks sane to me, but I'm not going to commit it, because I don't use Windows.

Ralf, if it looks good to you, please commit (to 1.6 or master, your call).
Comment 2 Simon McVittie 2014-01-06 15:57:30 UTC
Ralf, is this OK from your point of view? It would be good to get it in 1.8.
Comment 3 Ralf Habacker 2014-01-06 16:07:07 UTC
(In reply to comment #2)
> Ralf, is this OK from your point of view? It would be good to get it in 1.8.

Sorry for the delay, I thought I already committed this. May be I has been interrupted and did not push. Will take a look.
Comment 4 Ralf Habacker 2014-01-06 16:10:45 UTC
committed to master
Comment 5 Simon McVittie 2014-01-06 16:31:11 UTC
Fixed in git for 1.7.10

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.