bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] mark functions with const and pure attributes


From: Bruno Haible
Subject: Re: [PATCH 1/2] mark functions with const and pure attributes
Date: Sun, 1 May 2011 21:45:58 +0200
User-agent: KMail/1.9.9

Paul Eggert wrote:
> The declarations should be marked.  For example, the declaration of argmatch
> should be marked with _GL_ATTRIBUTE_PURE (or _GL_PURE) in argmatch.h.

Yes. Good point.

Jim, in the current idioms with macros from c++defs.h the attribute needs to
be added in the _GL_FUNCDECL_RPL and _GL_FUNCDECL_SYS invocations, but should
not be added in the _GL_CXXALIAS_RPL and _GL_CXXALIAS_SYS invocations.

Example from stdio.in.h:

  _GL_FUNCDECL_RPL (obstack_printf, int,
                    (struct obstack *obs, const char *format, ...)
                    _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
                    _GL_ARG_NONNULL ((1, 2)));
  _GL_CXXALIAS_RPL (obstack_printf, int,
                    (struct obstack *obs, const char *format, ...));
  # else
  #  if address@hidden@
  _GL_FUNCDECL_SYS (obstack_printf, int,
                    (struct obstack *obs, const char *format, ...)
                    _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
                    _GL_ARG_NONNULL ((1, 2)));
  #  endif
  _GL_CXXALIAS_SYS (obstack_printf, int,
                    (struct obstack *obs, const char *format, ...));

> This affects Bruno's point that the lines all have enough room
> for _GL_ATTRIBUTE_CONST etc.; I expect that point no longer holds
> once declarations are marked.

In these idioms you can reserve an extra line per attribute declaration.

In glibc, Ulrich Drepper hoisted as many attribute and other declarations
into as few lines as possible. You can see the result: inconsistent
formatting, and macros like __wur. Ugly.

Bruno
-- 
In memoriam Itzhak Katzenelson <http://en.wikipedia.org/wiki/Itzhak_Katzenelson>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]