Define JNIEXPORT as visibility default with GCC? (original) (raw)

David DeHaven 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:

./hotspot/src/cpu/x86/vm/jnix86.h #if defined(SOLARIS) || defined(LINUX) || defined(ALLBSDSOURCE) #if defined(GNUC) && (GNUC > 4) || (GNUC == 4) && (GNUCMINOR > 2) #define JNIEXPORT attribute((visibility("default"))) #define JNIIMPORT attribute((visibility("default"))) #else #define JNIEXPORT #define JNIIMPORT #endif

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.

-DrD-



More information about the core-libs-dev mailing list