>--[Christian Biere]--<[EMAIL PROTECTED]>
> R�diger Kuhlmann wrote:
> > > I assume this is no different from gettext() but GCC "trusts" the latter
> > > to not mess with format strings.
> > The "trust" is in no way different from checking format strings at all,
> > i.e., a simple __attribute__() thing,
> Which one?

Checking /usr/include/glib-2.0/glib/gmacros.h from libglib2.0-dev 2.4.8-1, I
can't find a glib macro for it. /usr/include/libintl.h from libc6-dev
2.3.2.ds1-20 uses this declaration:

extern char *ngettext (__const char *__msgid1, __const char *__msgid2,
                       unsigned long int __n)
     __THROW __attribute_format_arg__ (1) __attribute_format_arg__ (2);

where __attribute_format_arg__ is defined in /usr/include/sys/cdefs.h
(included through /usr/include/features.h) as:

#if __GNUC_PREREQ (2,8)
# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
#else
# define __attribute_format_arg__(x) /* Ignore */
#endif

Here's the documentation according to <info:/gcc-3.3/Function Attributes>:

`format_arg (STRING-INDEX)'
      The `format_arg' attribute specifies that a function takes a format
      string for a `printf', `scanf', `strftime' or `strfmon' style
      function and modifies it (for example, to translate it into
      another language), so the result can be passed to a `printf',
      `scanf', `strftime' or `strfmon' style function (with the
      remaining arguments to the format function the same as they would
      have been for the unmodified string).  For example, the
      declaration:


           extern char *
           my_dgettext (char *my_domain, const char *my_format)
                 __attribute__ ((format_arg (2)));


      causes the compiler to check the arguments in calls to a `printf',
      `scanf', `strftime' or `strfmon' type function, whose format
      string argument is a call to the `my_dgettext' function, for
      consistency with the format string argument `my_format'.  If the
      `format_arg' attribute had not been specified, all the compiler
      could tell in such calls to format functions would be that the
      format string argument is not constant; this would generate a
      warning when `-Wformat-nonliteral' is used, but the calls could
      not be checked without the attribute.


      The parameter STRING-INDEX specifies which argument is the format
      string argument (starting from one).  Since non-static C++ methods
      have an implicit `this' argument, the arguments of such methods
      should be counted from two.


      The `format-arg' attribute allows you to identify your own
      functions which modify format strings, so that GCC can check the
      calls to `printf', `scanf', `strftime' or `strfmon' type function
      whose operands are a call to one of your own function.  The
      compiler always treats `gettext', `dgettext', and `dcgettext' in
      this manner except when strict ISO C support is requested by
      `-ansi' or an appropriate `-std' option, or `-ffreestanding' is
      used.   Options Controlling C Dialect C Dialect Options.

Not particularly hard to find, is it?

-- 
"See, free nations are peaceful nations. Free nations don't attack
 each other. Free nations don't develop weapons of mass destruction."
      - George W. Bush, Milwaukee, Wis., Oct. 3, 2003


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Gtk-gnutella-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtk-gnutella-devel

Reply via email to