[PATCH wayland 3/4] scanner: make use of __has_attribute()

Pekka Paalanen ppaalanen at gmail.com
Thu Feb 22 10:22:56 UTC 2018


On Fri, 16 Feb 2018 16:22:32 +0000
Emil Velikov <emil.l.velikov at gmail.com> wrote:

> From: Emil Velikov <emil.velikov at collabora.com>
> 
> A more generic way to evaluating various attributes, __has_attribute is
> available with gcc, clang, even the Oracle/Sun compiler.
> 
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
>  src/scanner.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/scanner.c b/src/scanner.c
> index 679e006..c93070c 100644
> --- a/src/scanner.c
> +++ b/src/scanner.c
> @@ -1744,7 +1744,11 @@ emit_code(struct protocol *protocol, enum visibility vis)
>  	 * we want to have the symbols hidden. */
>  	if (vis == PRIVATE) {
>  		symbol_visibility = "WL_PRIVATE";
> -		printf("#if defined(__GNUC__) && __GNUC__ >= 4\n"
> +		printf("#ifndef __has_attribute\n"
> +		       "# define __has_attribute(x) 0  /* Compatibility with non-clang compilers. */\n"
> +		       "#endif\n\n");
> +
> +		printf("#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4\n"
>  		       "#define WL_PRIVATE __attribute__ ((visibility(\"hidden\")))\n"
>  		       "#else\n"
>  		       "#define WL_PRIVATE\n"

Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180222/1bf2e172/attachment-0001.sig>


More information about the wayland-devel mailing list