Re: bug formatting a .h function extern declaration with attribute macros

Simon Josefsson via Bug reports for the GNU m4 macro processor <[email protected]> Fri, 04 Apr 2025 17:48:25 +0200
Newsgroups gmane.comp.gnu.m4.bugs,gmane.comp.gnu.indent.bugs
Message-ID <[email protected]>
--=-=-=
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Eric Blake <[email protected]> writes:

> On Fri, Apr 04, 2025 at 02:16:03PM +0200, Simon Josefsson wrote:
>> Eric Blake <[email protected]> writes:
>>=20
>> >> #  define G_GNUC_IDN2_ATTRIBUTE_PURE __attribute__ ((pure))
>> ...
>> >>   extern _IDN2_API const char *idn2_check_version (const char *req_ve=
rsion)
>> >>     G_GNUC_IDN2_ATTRIBUTE_PURE;
>> >
>> > Figuring out how to write the __attribute__-hiding macros conditional
>> > on compiler version wasn't the issue (the m4 definitions for
>> > ATTRIBUTE_PURE come from gnulib, and are under a similar ladder of
>> > #if); rather, it's that an all-caps macro that takes no arguments and
>> > appears after the func(params) but before the trailing ; of an extern
>> > function declaration confuse indent.
>>=20
>> By formatting things like the above, without any '(())', then indent is
>> happy.  I run indent on the idn2.h and it looks like the above without
>> any INDENT-OFF.  If I included the '(())' part, then just like you I had
>> issues getting indent to behave.  The conditional part is unrelated to
>> the indent issue, but I can see that my recommendation was unclear.
>
> ATTRIBUTE_COLD wasn't necessarily the problem.  It was
> "ATTRIBUTE_FORMAT ((__printf__, 3, 4))".  And that one needs
> parameters, since it applies to a varargs that is not at a fixed
> location.

Would then the following not work?  The point is to move the (()) out
from the function declaration.

#define M4_ATTRIBUTE_FORMAT_PRINTF34 __attribute__ ((__format__ (__printf__=
, 3, 4)))

extern void
m4_error (int, int, const char *, ...)
     M4_ATTRIBUTE_FORMAT_PRINTF34;

/Simon

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQNoBAEWCAMQFiEEo8ychwudMQq61M8vUXIrCP5HRaIFAmfv/0oUHHNpbW9uQGpv
c2Vmc3Nvb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