sentinel and printf check macros

Roland Mainz roland.mainz at nrubsig.org
Thu Apr 28 16:07:33 PDT 2005


Adam Jackson wrote:
> On Wednesday 27 April 2005 11:29, Egbert Eich wrote:
> > gcc-4 has checks for sentinels (terminating NULL in varargs lists)
> > and printf-like lists which can be controlled by attributes.
> >
> > The sentinel check catches code that terminates a varargs list with
> > 0 instead of NULL which causes problems on 64bit systems.
> > The printf check is useful to check a variable list against a format
> > string.
> > It would make sense to add these attributes to function declaration
> > in header files if the compiler supports them.
> > I therefore propose to add the following macros to include/Xfuncproto.h:
> >
> > +#if defined(__GNUC__) && (__GNUC__ >= 4)
> > +# define _X_SENTINEL(x) __attribute__ ((__sentinel__(x)))
> > +# define _X_ATTRIBUTE_PRINTF(x,y)
> > __attribute__((__format__(__printf__,x,y))) +#else
> > +# define _X_SENTINEL(x)
> > +# define _X_ATTRIBUTE_PRINTF(x,y)
> > +#endif /* GNUC >= 4 */
> >
> > Since Xfuncproto.h so far doesn't contain any compiler specific macro
> > definition this would be a new thing.
> > I therefore post it here for discussion.
> >
> > Any thoughts?
> 
> Xfuncproto.h is probably the logical place.  I was considering doing something
> similar in compiler.h but that's not visible from the clients.  Sounds good
> to me.

What about introducing a Xcompiler.h to handle all compiler-specific
optimisations there ?

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz at nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)


More information about the xorg-arch mailing list