Re: Rust kernel policy

Martin Uecker
2025-02-21T18:31:27Z

Am Freitag, dem 21.02.2025 um 10:07 -0800 schrieb Linus Torvalds:
> On Fri, 21 Feb 2025 at 09:42, Steven Rostedt <rostedt@goodmis.org> wrote:
> >
> > Because they are arcane and even the gcc documentation recommends avoiding
> > them.
> >
> > "Note that in general we do not recommend the use of pragmas"
> > https://gcc.gnu.org/onlinedocs/gcc/Pragmas.html
>
> Yeah, #pragma is complete garbage and should never be used. It's a
> fundamentally broken feature because it doesn't work AT ALL with a
> very core piece of C infrastructure: the pre-processor.
>
> Now, we all hopefully know that the C pre-processor is the _real_
> fundamental problem here in how limited it is, but it is what it is.
> Given the fact of how weak C pre-processing is, adding a feature like
> #pragma was a complete failure.

Isn't this what _Pragma() is for?

>
> So gcc - and other compilers - have figured out alternatives to pragma
> that actually work within the context of the C pre-processor. The main
> one tends to be to use __attribute__(()) to give magical extra
> context.

The issue with __attribute__ is that it is always tied to a specific
syntactic construct. Possible it could be changed, but then I do
not see a major difference to _Pragma, or?

...[Linus' rant]...

>
> This is non-negotiable. Anybody who thinks that a compiler is valid
> warning about
>
> if (x < 0 || x >= 10) {
>
> just because 'x' may in some cases be an unsigned entity is not worth
> even discussing with.

Do you think the warning is useless in macros, or in general?

Martin