On 10/3/23 08:19, Joseph Myers wrote:
On Mon, 2 Oct 2023, Sandra Loosemore wrote:

Going beyond that, though, I think we should also document that the standard
syntax is now the preferred way to do it, and change the examples (except for
the parts documenting the old syntax) to use the new standard syntax.  It's
been accepted by the default -std= setting for both C and C++ since GCC 10,
and my understanding is that C2x will be official by the time GCC 14 is
released (so supporting the new syntax won't be just another GNU extension any
more). Does this sound OK to everybody?

If you're documenting attributes in the [[]] form, you need to be a lot
more careful to distinguish between an attribute on a declaration and one
on the type of that declaration, for example, because those need to go in
different places in the standard syntax (the laxity applied with
__attribute__ that tries to guess what was meant and e.g. move an
attribute from a declaration to its type doesn't apply with the standard
syntax, which has precise rules in the standard for what entity an
attribute in a given syntactic position appertains to).  In some cases
this means that the [[]] attribute needs to go in a different position
from __attribute__ in examples [snip]

Right, I was aware I couldn't just do a simple text substitution here without at least hand-checking that the examples still have the intended effect! I'm estimating this as a medium-sized documentation project of the kind I typically do around the end of the year when we are in stage 3, although since life is uncertain I'd like to get in the more minimal fix (to at least mention the C/C++ standard attribute syntax) sooner. My question was more about whether there was objection in principle to doing the rewrite. I recall that for a very long time we were telling people to use __attribute__ instead of pragmas, and basically telling people to avoid #pragma entirely, for example. Is __attribute__ also considered more powerful than the standard [[]] syntax, enough to recommend it over writing standard-conforming code?

-Sandra

Reply via email to