[Top][All Lists]

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

test for visibility

From: James K. Lowden
Subject: test for visibility
Date: Wed, 25 Apr 2012 16:05:24 -0400

I would like to be able to test whether or not the preprocessor
supports the visibility pragma.   My program today says:

#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
#pragma GCC visibility push(hidden)

which cries out for a feature test

#pragma GCC visibility push(hidden)

because e.g. clang defines GCC. 

My search of the docs and the m4 macro archive didn't turn up anything,
so I thought maybe I'd contribute one.  The macro below almost works,
but for the fact that clang only warns about the construct.  (It is
the warnings I would like to squelch.)  

How do I tell the compiler to use -Werror within an m4 macro?  I see
AC_LANG_WERROR and AC_PROG_CPP_WERROR, but afaict they aren't available
within m4.  Alternatively, how can I construct a macro that returns
"no" if the compiler issues a diagnostic?  

Text of the macro follows.  Many thanks for your advice.  


dnl Test whether or not the compiler supports visibility
 [AC_CACHE_CHECK([whether the compiler supports visibility],
#pragma GCC visibility push(hidden)
int i;
  if test $ac_cv_have_pragma_visibility = yes; then
        [Define to 1 if your system supports pragma GCC visibility.])

reply via email to

[Prev in Thread] Current Thread [Next in Thread]