autoconf
[Top][All Lists]
Advanced

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

Re: Testing for compiler capabilities


From: Jan Engelhardt
Subject: Re: Testing for compiler capabilities
Date: Tue, 22 Aug 2006 20:06:32 +0200 (MEST)

Hi David,

>> is there a simple macro that will test for a specific compiler flag and set
>> a variable in both Makefile and config.h?
>> I am looking for an easy way to test for GCC's -fvisibility=hidden and
>> have an indicator whether or not it is available in said files.
>
>       Here's (attached) a test for visibility attributes instead of
>visibility flags, which might give the same effect.  It defines the
>config.h variables HAVE_ATTRIBUTE_VISIBILITY_HIDDEN and
>HAVE_ATTRIBUTE_VISIBILITY_DEFAULT if the respective attributes are
>understood.  You can easily add an AM_CONDITIONAL to it as well.  This
>particular test runs in C++ mode.  I had to temporarily add the -Werror
>flag to the compile flags to make the compiler reject warnings about
>unsupported attributes.  Feedback is welcome.

I am afraid using -Werror does not work, it really needs -fvis.. on the 
command line:

$ cat x.c
int __attribute__((visibility("hidden"))) mx(void) { return 1337; }
$ cc -c x.c -Wall -Werror
(No error)
$ cc -c x.c -Wall -Werror -fvisibility=hidden
cc1: error: unrecognized option `-fvisibility=hidden'



Jan Engelhardt
-- 




reply via email to

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