Date: Tue, 6 Jan 2026 16:21:49 -0600
On Tue, Jan 6, 2026 at 3:03 PM Thiago Macieira via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> On Tuesday, 6 January 2026 17:11:25 Brasilia Standard Time Jens Maurer via
> Std-Proposals wrote:
> > My point is that there's no point in optimizing the design in
> > that respect. Those that "#define x" to something deserve to
> > be broken.
>
> I agree with the sentiment, but cleaning up may be difficult. There are
> quite a
> few very old APIs that do #define of lowercase entities.
>
> Just a quick examples found by grepping through my /usr/include that
> aren't
> expanding to other identifiers and aren't function-like macros:
>
> X11:
> #define black_width 16
> #define target_width 16
> #define target_height 16
> #define xterm_width 48
> #define xterm_height 48
> #define numInputClasses 7
>
> Linux/POSIX:
> #define sa_handler _u._sa_handler
> #define si_pid _sifields._kill._pid
> #define s6_addr in6_u.u6_addr8
>
> #define no_argument 0
> #define required_argument 1
> #define optional_argument 2
>
> POSIX ncurses:
> #define columns CUR Numbers[0]
> #define lines CUR Numbers[2]
>
> glib:
> it basically reserves the g_ prefix its entirety for itself
>
> OpenSSL:
> # define ub_name 32768
> #define acpted_rply ru.RM_rmb.ru.RP_ar
>
> MySQL/MariaDB:
> #define packet_error ((unsigned int) -1)
> #if defined(_WIN64)
> #define my_socket unsigned long long
> #elif defined(_WIN32)
> #define my_socket unsigned int
> #else
> typedef int my_socket;
> #endif
>
> Eigen:
> #define advanceRows ((LhsIsReal) ? 1 : 2)
>
> Zlib:
> # define local static
>
> And you may remember Qt's
> #define signals public
> #define slots
> #define emit
>
> I won't even go into Win32, with things like:
> #define small char
> #define interface struct
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Are macros something that really need to be considered for this facility?
In theory, we have modules. In practice, we have #pragma
push_macro/pop_macro — which are a bit tedious to use since it takes 3
lines of code per macro name, but it is at least possible to temporarily
undefine a macro if a library author really wants to be friendly.
Also there's relevant history here. In C++20, we added two new types which
had a public member function (not parameter) named emit, which obviously
conflicts with Qt's macro as you're pointing out. But LWG3399 (
https://cplusplus.github.io/LWG/issue3399) was decided to be not a defect,
and the name stayed (e.g. https://eel.is/c++draft/syncstream.syncbuf.members).
For what it's worth, that vote wasn't close either (2 in favor of renaming
emit, 28 opposed).
Barry
std-proposals_at_[hidden]> wrote:
> On Tuesday, 6 January 2026 17:11:25 Brasilia Standard Time Jens Maurer via
> Std-Proposals wrote:
> > My point is that there's no point in optimizing the design in
> > that respect. Those that "#define x" to something deserve to
> > be broken.
>
> I agree with the sentiment, but cleaning up may be difficult. There are
> quite a
> few very old APIs that do #define of lowercase entities.
>
> Just a quick examples found by grepping through my /usr/include that
> aren't
> expanding to other identifiers and aren't function-like macros:
>
> X11:
> #define black_width 16
> #define target_width 16
> #define target_height 16
> #define xterm_width 48
> #define xterm_height 48
> #define numInputClasses 7
>
> Linux/POSIX:
> #define sa_handler _u._sa_handler
> #define si_pid _sifields._kill._pid
> #define s6_addr in6_u.u6_addr8
>
> #define no_argument 0
> #define required_argument 1
> #define optional_argument 2
>
> POSIX ncurses:
> #define columns CUR Numbers[0]
> #define lines CUR Numbers[2]
>
> glib:
> it basically reserves the g_ prefix its entirety for itself
>
> OpenSSL:
> # define ub_name 32768
> #define acpted_rply ru.RM_rmb.ru.RP_ar
>
> MySQL/MariaDB:
> #define packet_error ((unsigned int) -1)
> #if defined(_WIN64)
> #define my_socket unsigned long long
> #elif defined(_WIN32)
> #define my_socket unsigned int
> #else
> typedef int my_socket;
> #endif
>
> Eigen:
> #define advanceRows ((LhsIsReal) ? 1 : 2)
>
> Zlib:
> # define local static
>
> And you may remember Qt's
> #define signals public
> #define slots
> #define emit
>
> I won't even go into Win32, with things like:
> #define small char
> #define interface struct
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Are macros something that really need to be considered for this facility?
In theory, we have modules. In practice, we have #pragma
push_macro/pop_macro — which are a bit tedious to use since it takes 3
lines of code per macro name, but it is at least possible to temporarily
undefine a macro if a library author really wants to be friendly.
Also there's relevant history here. In C++20, we added two new types which
had a public member function (not parameter) named emit, which obviously
conflicts with Qt's macro as you're pointing out. But LWG3399 (
https://cplusplus.github.io/LWG/issue3399) was decided to be not a defect,
and the name stayed (e.g. https://eel.is/c++draft/syncstream.syncbuf.members).
For what it's worth, that vote wasn't close either (2 in favor of renaming
emit, 28 opposed).
Barry
Received on 2026-01-06 22:22:07
