]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
compiler_types.h: add "auto" as a macro for "__auto_type"
authorH. Peter Anvin <hpa@zytor.com>
Fri, 18 Jul 2025 18:35:00 +0000 (11:35 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Jan 2026 09:17:09 +0000 (10:17 +0100)
commit6cce897a37dc9813c7b70a7ebe4f5f14aa604c8d
treeaa44812bb8b9259385a4634520dfff41a80cbfca
parent089e50f29eeec8eef6ae1450fc88138d719291cb
compiler_types.h: add "auto" as a macro for "__auto_type"

commit 2fb6915fa22dc5524d704afba58a13305dd9f533 upstream.

"auto" was defined as a keyword back in the K&R days, but as a storage
type specifier.  No one ever used it, since it was and is the default
storage type for local variables.

C++11 recycled the keyword to allow a type to be declared based on the
type of an initializer.  This was finally adopted into standard C in
C23.

gcc and clang provide the "__auto_type" alias keyword as an extension
for pre-C23, however, there is no reason to pollute the bulk of the
source base with this temporary keyword; instead define "auto" as a
macro unless the compiler is running in C23+ mode.

This macro is added in <linux/compiler_types.h> because that header is
included in some of the tools headers, wheres <linux/compiler.h> is
not as it has a bunch of very kernel-specific things in it.

[ Cc: stable to reduce potential backporting burden. ]

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Acked-by: Miguel Ojeda <ojeda@kernel.org>
Cc: <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/compiler_types.h