public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: i.nixman@autistici.org
Cc: gdb@sourceware.org
Subject: Re: _WIN32_WINNT redefined?
Date: Wed, 02 Nov 2022 14:50:57 +0200	[thread overview]
Message-ID: <8335b1bjv2.fsf@gnu.org> (raw)
In-Reply-To: <b5af235408fe3c36bb85961f3192367b@autistici.org> (message from niXman via Gdb on Wed, 02 Nov 2022 09:46:20 +0000)

> Date: Wed, 02 Nov 2022 09:46:20 +0000
> From: niXman via Gdb <gdb@sourceware.org>
> 
> On 2022-11-02 08:44, niXman via Gdb wrote:
> > On 2022-11-02 08:21, niXman via Gdb wrote:
> 
> ok, I did a little research.
> 
> the `_WIN32_WINNT` is defined in `gdbsupport/common-defs.h` only, but 
> referenced in `gnulib/import/gettimeofdeay.c` and 
> `gnulib/import/stat-w32.c` only, but not directly because those files 
> include `windows,h` and `sdkdkver.h`. thus that `_WIN32_WINNT` define is 
> never used!

No, _WIN32_WINNT is referenced in a lot of w32api header files, which
use it to decide whether to expose function prototypes, data type
declarations, macros, etc.  In effect, the value of _WIN32_WINNT
determines the oldest version of MS-Windows which the program needs to
support, by hiding APIs that are not available on later versions --
this ensures the program doesn't use those later APIs unintentionally.

> so I think the best way is to remove that define completely.

No, that's wrong, because if you remove that, you will basically force
everyone who builds GDB for Windows to use the default value of
_WIN32_WINNT defined by the w32api headers.  And that default is not
necessarily what we want.

> ideas?

Find out why the current definition causes trouble in your build, then
we could discuss the correct solution that works for everyone.

In the original report you said:

> In file included from 
> mingw64/lib/gcc/x86_64-w64-mingw32/13.0.0/include/c++/mutex:45,
>                   from 
> ../src/gdb-11.2/gdbsupport/../gdbsupport/thread-pool.h:27,
>                   from ../src/gdb-11.2/gdbsupport/thread-pool.cc:24:
> mingw64/lib/gcc/x86_64-w64-mingw32/13.0.0/include/c++/bits/std_mutex.h:163:5: 
> error: '__gthread_cond_t' does not name a type; did you mean 
> '__gthread_once_t'?
>    163 |     __gthread_cond_t* native_handle() noexcept { return 
> &_M_cond; }
>        |     ^~~~~~~~~~~~~~~~
> ```
> 
> the problem is a consequence of the fact that `_WIN32_WINNT` is 
> redefined somewhere to another value that is less than necessary.
> but when I pass `-D_WIN32_WINNT=0x0601` for CFLAGS/CXXFLAGS - the 
> trouble is gone.

This doesn't explain why -D_WIN32_WINNT=0x0601 solves the problem.
Can you explain that in enough detail, and point to the relevant parts
of the headers?

In addition, you point to this place in common-defs.h:

  /* We don't support Windows versions before XP, so we define
     _WIN32_WINNT correspondingly to ensure the Windows API headers
     expose the required symbols.  */
  #if defined (__MINGW32__) || defined (__CYGWIN__)
  # ifdef _WIN32_WINNT
  #  if _WIN32_WINNT < 0x0501
  #   undef _WIN32_WINNT
  #   define _WIN32_WINNT 0x0501
  #  endif
  # else
  #  define _WIN32_WINNT 0x0501
  # endif
  #endif	/* __MINGW32__ || __CYGWIN__ */

This defines _WIN32_WINNT only if it wasn't already defined, or if it
was defined to a value smaller than 0x0501.  So why isn't _WIN32_WINNT
defined in your w32api headers?  It should be defined to some default
value, which was determined when the w32api headers were produced, and
I'm guessing that this default value should be 0x0601, in which case
the above preprocessor stuff should not redefine it.

  parent reply	other threads:[~2022-11-02 12:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-02  8:14 i.nixman
2022-11-02  8:21 ` i.nixman
2022-11-02  8:44   ` i.nixman
2022-11-02  9:46     ` i.nixman
2022-11-02 10:15       ` i.nixman
2022-11-02 12:59         ` Eli Zaretskii
2022-11-02 13:10           ` Jeffrey Walton
2022-11-02 13:26             ` Eli Zaretskii
2022-11-02 12:50       ` Eli Zaretskii [this message]
2022-11-02 14:13         ` i.nixman
2022-11-02 15:18           ` Eli Zaretskii
2022-11-02 15:51             ` i.nixman
2022-11-02 16:02               ` i.nixman
2022-11-02 16:51               ` Eli Zaretskii
2022-11-02 17:20                 ` i.nixman
2022-11-02 18:13                   ` Eli Zaretskii
2022-11-02 12:55     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8335b1bjv2.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb@sourceware.org \
    --cc=i.nixman@autistici.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).