Commit bd926893 authored by Emil Velikov's avatar Emil Velikov Committed by Pekka Paalanen

scanner: make use of __has_attribute()

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's avatarEmil Velikov <>
Reviewed-by: Pekka Paalanen's avatarPekka Paalanen <>
Reviewed-by: default avatarDerek Foreman <>
parent ab6b1569
......@@ -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"
printf("#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4\n"
"#define WL_PRIVATE __attribute__ ((visibility(\"hidden\")))\n"
"#define WL_PRIVATE\n"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment