sentinel and printf check macros

Adam Jackson ajax at nwnk.net
Wed Apr 27 12:58:40 PDT 2005


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.

- ajax
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.x.org/archives/xorg-arch/attachments/20050427/54e90855/attachment.pgp


More information about the xorg-arch mailing list