Re: windows build slow due to windows.h includes

From: Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: windows build slow due to windows.h includes
Date: 2021-09-22 07:06:03
Message-ID: CAC+AXB2Etm0hJeBpODgFOaYE=DTPqYfQ5QDthcQDoUNX_uaAyg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 22, 2021 at 1:56 AM Andres Freund <andres(at)anarazel(dot)de> wrote:

> On 2021-09-21 20:26:36 -0300, Ranier Vilela wrote:
> > Em ter., 21 de set. de 2021 às 16:30, Andres Freund <andres(at)anarazel(dot)de>
> > escreveu:
> > > But that's too much work for my taste. As it turns out there's a
> partial
> > > solution to windows.h being just so damn big, the delightfully named
> > > WIN32_LEAN_AND_MEAN.
> > >
> > +1
> > But I did a quick dirty test here, and removed windows.h in win32_port.h,
> > and compiled normally with msvc 2019 (64 bit), would it work with mingw
> > cross compile?
>
> That's likely only because winsock indirectly includes windows.h - because
> of
> that it won't actually reduce compile time. And you can't remove the other
> headers that indirectly include windows.h without causing compilation
> errors.
>
> You are right about winsock2.h including some parts of windows.h, please
see note in [1]. You could move the windows.h inclusion for clarity:

+ #ifndef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN
+ #endif
+
+ #include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
- #include <windows.h>

[1]
https://docs.microsoft.com/en-us/windows/win32/winsock/creating-a-basic-winsock-application

Regards,

Juan José Santamaría Flecha

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2021-09-22 07:27:39 Re: Timeout failure in 019_replslot_limit.pl
Previous Message Peter Eisentraut 2021-09-22 06:59:38 Re: Proposal: Save user's original authenticated identity for logging