GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/mingw-w64

Prevent mingw-w64 from undefining _REENTRANT when using pthreads

Correct mingw-w64 spec to always define _REENTRANT when pthreads are enabled, avoiding conflicts.

The mingw-w64 compiler configuration incorrectly undefined the _REENTRANT macro when the -pthread flag was used, despite pthreads being enabled. This could lead to threading issues. This commit modifies the CPP_SPEC to ensure _REENTRANT is always defined when pthreads are requested, whether by default or explicitly via -pthread, and removes an unnecessary empty spec for SPEC_PTHREAD2 to prevent potential misuse.

In Details

The CPP_SPEC for mingw-w64 incorrectly had a conditional -U_REENTRANT that was activated by -pthread, conflicting with the intention of enabling threading support. This commit modifies the spec to ensure _REENTRANT is defined when pthreads are requested (!no-pthread or -pthread), and removes the redundant SPEC_PTHREAD2 from this section to prevent it from expanding to nothing and potentially causing issues.

For Context
_REENTRANT
A preprocessor macro that enables reentrant (thread-safe) versions of certain C library functions.
mingw-w64
A project providing a development environment for Windows, including GCC toolchains.
CPP_SPEC
A GCC spec string that defines default preprocessor options.
pthread
POSIX Threads, an API for creating and managing threads in a multi-threaded application.
Filed Under: mingw-w64threadingspecspreprocessor