Define JNIEXPORT as visibility default with GCC?

David DeHaven david.dehaven at
Thu Feb 14 23:01:38 UTC 2013

>>>> +#if defined(__GNUC__) && (__GNUC__ > 4) || (__GNUC__ == 4) &&
>>>> (__GNUC_MINOR__ > 2)
>>>> +  #define JNIEXPORT     __attribute__((visibility("default")))
>>>> +  #define JNIIMPORT     __attribute__((visibility("default")))
>>> The default compiler in Xcode 4.1 is llvm-gcc 4.2, it seems.  The conditional above excludes that.  Is this intentional?
>> It's *is* gcc, with a LLVM backend.
> Yes, but it identifies itself as GCC 4.2, so the conditional doesn't fire.

I assume this was not the intent and the version check is just wrong.

> If Xcode is fine with the #define, I suggest to drop the version check completely.  We already do not support compiling with GCC versions which are so old that they lack visibility support.

If it were Mac only, I'd agree.

The same header is currently used for all "unix-like" OS's (which may change, if I have my way), so Solaris and Linux would also be affected. Most Linux distros have used gcc 4 for quite a while now, I've no idea what Solaris uses and embedded targets are a wild mishmash of whatever someone manages to cobble together, so the simpler __GNUC__ check may still be appropriate.


More information about the core-libs-dev mailing list