autoconf
[Top][All Lists]
Advanced

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

Re: test for visibility


From: Andrew W. Nosenko
Subject: Re: test for visibility
Date: Thu, 26 Apr 2012 03:21:13 +0300

On Wed, Apr 25, 2012 at 23:05, James K. Lowden <address@hidden> wrote:
> 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)
> #endif
>
> which cries out for a feature test
>
> #if HAVE_PRAGMA_VISIBILITY
> #pragma GCC visibility push(hidden)
> #endif
>
> because e.g. clang defines GCC.

Ok, but what if compiler does not support "#pragma GCC visibility",
what you plan to do?

The reason of question: if samples above are full, i.e. you indeed
don't have #else part, then you just don't need the #if at all.

If compiler supports "#pragma GCC visibility" then it will execute it
with #if (because HAVE_PRAGMA_VISIBILITY will be defined) or without.
If compiler doesn't support it, then pragma GCC visibility will be
skipped with #if (because undefined HAVE_PRAGMA_VISIBILITY) or without
(just because unknown pragmas are ignored per standard).

-- 
Andrew W. Nosenko <address@hidden>



reply via email to

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