Re: [xml] ATTRIBUTE_PRINTF in xmlversion.h



On Tue, Mar 31, 2009 at 07:30:40PM +0200, Mike Hommey wrote:
Hi,

It would be nice from Daniel or others to respond to the following
message, we had the same issue in Debian.

  Yup, understood, it's basically a macro name clash, we nearly
got the issue with libvirt which is using ATTRIBUTE_FORMAT for the same
thing. I don't want to try to guess what may come from ansidecl.h
and if it's exactly the same as what we are defining. The simplest is
just to avoid the naming clash so I think renaming ATTRIBUTE_PRINTF
as LIBXML_ATTR_FORMAT with everthing else keep the same should be
sufficient to avoid those issues, hopefully the LIBXML_ prefix is
a specific enough namespace to avoid any future conflict.
  I have commited this in SVN, I guess it should solve the problem,

   thanks !

Daniel

On Tue, Mar 03, 2009 at 07:05:21AM +0100, Belgabor wrote:
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
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



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