Define JNIEXPORT as visibility default with GCC?
david.dehaven at oracle.com
Thu Feb 14 19:07:42 UTC 2013
> This seems like an obvious improvement.
> There are already bunches of places in the jdk sources that do things like:
> #if defined(SOLARIS) || defined(LINUX) || defined(_ALLBSD_SOURCE)
> #if defined(__GNUC__) && (__GNUC__ > 4) || (__GNUC__ == 4) &&
> (__GNUC_MINOR__ > 2)
> #define JNIEXPORT __attribute__((visibility("default")))
> #define JNIIMPORT __attribute__((visibility("default")))
> #define JNIEXPORT
> #define JNIIMPORT
That version check didn't work for me running on Mac OS X (using llvm-gcc 4.2). If that's what hotspot is using then they may not be getting the desired effect. The problem is __GNUC_MINOR__ is 2, so it needs to be changed to >= 2.
Gnu recommends just using "#if __GNUC__ >= 4", and everything I've read about it says it's 4.0 and later, so I don't understand why the minor version check is even in there.
More information about the core-libs-dev