On 2025-05-12 20:25, Elliott Mitchell wrote:
On Mon, May 12, 2025 at 03:00:18PM +0200, Jan Beulich wrote:
On 12.05.2025 14:09, Andrew Cooper wrote:
>
> Now for the (new) controversial part. Since sending this, Linux has
> decided to just #define auto __auto_type for C < 23, in order to start
> writing C23 compatible code from now. It's more succinct, and has
> better longevity.
>
> We might want to consider the same, although it will introduce a new
> example of defining a keyword, which we'd have to call out in the
> MISRA/Eclair config.
I'm not outright opposed, as I don't think we use "auto" with its
original semantics, but it feels somewhat odd.
Problem is "auto" already has a defined meaning in C. Having this will
subtly break contributions from authors who weren't familiar with
everything in Xen's headers. For anyone who does anything with
projects
besides Xen this will encourage bad habits.
I believe many projects have a rule of *never* #define C keywords. I'm
surprised such made it into the Linux kernel. I expect it will be
ripped
out in the near future.
MISRA *doesn't* absolutely forbid this?
It does, and in fact I don't think that is a wise decision (it's not
quite UB I think because Xen does not use standard library headers, but
still). However Xen does already #define "inline" with a specific
rationale. I could find only [1] as a reference to the discussion in
Linux, but perhaps I missed something. Do you have more recent thread
@Andrew?
[1]
https://lore.kernel.org/lkml/d4f87590-6cbb-4ee9-bead-7d958fc1fa83@p183/#R
--
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253