https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78920
Bug ID: 78920
Summary: libstdc++ defines a macro named "major"
Product: gcc
Version: 6.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: zhouyan at me dot com
Target Milestone: ---
Here is a minimal example,
#include <iostream>
#ifdef major
#error
#endif
The example check if there's a macro named "major" defined. I observed this
recently when one of my function in my library named "major" started to break,
and the compiler error message says that "gnu_dev_major" was called with
incorrect number of arguments. This is the typical error when a function takes
the same name as a macro.
The above example will compile fine (major macro not defined) with clang 3.9.1,
g++ 4.8.5, as well as g++ 6.3.1 on macOS. However, it will emit error with g++
6.3.1 on Linux.
I saw I very old bug report #17130 about the same issue. But the system GCC
4.8.5 somehow undefined this macro while the vanilla GCC 6.3 (installed without
any special configuration options, except --prefix and --program-suffix) does
not. Are there some configuration options during installation that lead to the
behavior of the system compiler?