[xml] ATTRIBUTE_PRINTF in xmlversion.h



Hi everybody,

I have a (somewhat) serious problem with the definition of ATTRIBUTE_PRINTF in xmlversion.h.

The definition reads:
/**
 * ATTRIBUTE_PRINTF:
 *
 * Macro used to indicate to GCC the parameter are printf like
 */

#ifndef ATTRIBUTE_PRINTF
# if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
# define ATTRIBUTE_PRINTF(fmt,args) __attribute__((__format__(__printf__,fmt,args)))
# else
#  define ATTRIBUTE_PRINTF(fmt,args)
# endif
#else
# define ATTRIBUTE_PRINTF(fmt,args)
#endif


There are two issues with that. First, ansidecl.h, coming from the GNU C library defines it as:
/* Use ATTRIBUTE_PRINTF when the format specifier must not be NULL.
   This was the case for the `printf' format attribute by itself
   before GCC 3.3, but as of 3.3 we need to add the `nonnull'
   attribute to retain this behavior.  */
#ifndef ATTRIBUTE_PRINTF
#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m)
#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
#define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
#endif /* ATTRIBUTE_PRINTF */

so it defines ATTRIBUTE_PRINTF_1 et al as well, but is guarded only by ATTRIBUTE_PRINTF. This declaration is shared by wxWidgets, which is the library I have issues with. If I now include xmlversion.h before the wxWidgets library, the ATTRIBUTE_PRINTF in it prevents the definition of the _X macros.

Now if I'd change the order of inclusion (which would in fact be bothersome), the redefinition in xmlversion.h in the #else clause would actually make the macro evaluate to nothing!

I don't know how to properly fix that, but my first try would be to include ansidecl.h instead of defining it yourself, depending on GCC and version. And for all thats good and holy, don't nullify it if it's already defined.

Cheers
Tobias



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