GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
gcc/system.h

gcc/system.h: Allow conditional include of <iterator>.

Includes <iterator> conditionally in system.h to resolve macro conflicts.

The gcc/system.h header now conditionally includes <iterator> when INCLUDE_ITERATOR is defined. This change resolves a conflict where the toupper macro, defined in <locale_facets.h>, was being passed two arguments when <iterator> was included transitively, causing a compile error. The fix allows users to opt into including <iterator> when necessary without triggering the macro issue.

In Details

This commit adds a conditional include of <iterator> within gcc/system.h, guarded by #ifdef INCLUDE_ITERATOR. This addresses a specific macro collision issue where the toupper macro in <locale_facets.h> receives spurious arguments when <iterator> is included indirectly through C++ standard library headers, preventing compilation errors in certain toolchain configurations.

For Context
system.h
A header file in GCC that provides system-specific definitions and includes necessary system headers.
macro
A piece of code in C/C++ that is given a name. When the code is compiled, the preprocessor replaces the name with the code associated with that name. Macros can be simple text substitutions or more complex.
toupper
A standard C library macro (or function) that converts a lowercase character to its uppercase equivalent.
iterator
In C++, an object that enables traversal through a container (like a list or array) and access to its elements.
Filed Under: buildgccheader handlingcompiler