News for hackers. Stuff that matters.
Re:Three new utility functions in C++23 by s28l on Wednesday November 09, 2022 @10:48AM (#33533295)
I meant that they are processed before any syntactical analysis, so they're not particularly useful for this kind of thing. For example, these are all wrong usages of our hypothetical `#pragma unreachable`:

    void foo();
    #pragma unreachable
    class bar
    {
    #pragma unreachable
    };
    namespace foobar {
    #pragma unreachable
    }
But pragmas can generally be used anywhere, barring tokenization issues. The end result is that `pragma unreachable` would likely end up turning into a magic function call inside the compiler, since it really only makes sense in a spot where you can invoke a function.

Also, I think you are conflating pragmas with `__attribute__`, which is how you set per function optimization settings. If you do that with pragmas, then it isn't limited to a single function.

Re:Three new utility functions in C++23 by addaon on Wednesday November 09, 2022 @11:10AM (#33533647)
This is the intent and purpose of _Pragma; it provides a way to use existing #pragmas that are tokenized and handled a bit later, so they can e.g. be included in macro expansions.
Re:Three new utility functions in C++23 by s28l on Wednesday November 09, 2022 @11:21AM (#33533820)
I think the only benefit of `_Pragma` is that it enables defining a macro that expands into a `#pragma` definition. I don't think there's any other use case beyond that.
Re:Three new utility functions in C++23 by gpderetta on Wednesday November 09, 2022 @03:33PM (#33537440)
If pragma works for omp for it would work for unreachable. But it is just ugly and there really wouldn't be any reason to use it here.