From: Alexey Dobriyan <adobriyan@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, adobriyan@gmail.com
Subject: [PATCH 2/3] auto: add "auto" keyword as alias for __auto_type
Date: Tue, 16 May 2023 19:49:46 +0300 [thread overview]
Message-ID: <20230516164947.86543-2-adobriyan@gmail.com> (raw)
In-Reply-To: <20230516164947.86543-1-adobriyan@gmail.com>
It has similar semantics to "auto" keyword from a language
which can not be named on this mailing list, in particular:
{
int a;
const auto b = a; // const char b = a;
b = 1; // compile error
}
{
char a;
auto b = a; // char b = a;
// no integer promotions
static_assert(sizeof(b) == 1);
}
{
int a;
const auto p = &a; // int *const p = &a;
*p = 1; // works because const is applied only to top-level
}
It can be used to save on macroexpansion inside macro forests which
use typeof() somewhere deep enough. It is cool regardless.
Use "auto" in your code today!
gcc 5.1 supports __auto_type.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/Makefile b/Makefile
index 10fcc64fcd1f..d316924a466a 100644
--- a/Makefile
+++ b/Makefile
@@ -570,6 +570,7 @@ KBUILD_CFLAGS += -Werror=return-type
KBUILD_CFLAGS += -Werror=strict-prototypes
KBUILD_CFLAGS += -Wno-format-security
KBUILD_CFLAGS += -Wno-trigraphs
+KBUILD_CFLAGS += -Dauto=__auto_type
KBUILD_CPPFLAGS := -D__KERNEL__
KBUILD_RUSTFLAGS := $(rust_common_flags) \
--
2.40.1
next prev parent reply other threads:[~2023-05-16 16:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 16:49 [PATCH 1/3] auto, kbuild: flatten KBUILD_CFLAGS Alexey Dobriyan
2023-05-16 16:49 ` Alexey Dobriyan [this message]
2023-05-16 21:39 ` [PATCH 2/3] auto: add "auto" keyword as alias for __auto_type Andrew Morton
2023-05-16 23:18 ` Linus Torvalds
2023-05-17 6:20 ` Alexey Dobriyan
2023-05-16 16:49 ` [PATCH 3/3] auto, proc: use "auto" instead of quite chatty macros Alexey Dobriyan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230516164947.86543-2-adobriyan@gmail.com \
--to=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome