|
36 | 36 | #ifndef IE_CORE_EXPORT_H |
37 | 37 | #define IE_CORE_EXPORT_H |
38 | 38 |
|
39 | | -// define platform-specific macros for importing/exporting symbols |
| 39 | +// Define platform-specific macros for importing/exporting symbols |
40 | 40 | #ifdef _MSC_VER |
41 | 41 | #define IECORE_IMPORT __declspec(dllimport) |
42 | 42 | #define IECORE_EXPORT __declspec(dllexport) |
43 | 43 | #else |
44 | | - #define IECORE_IMPORT |
45 | | - #define IECORE_EXPORT |
| 44 | + #define IECORE_IMPORT __attribute__((visibility("default"))) |
| 45 | + #define IECORE_EXPORT __attribute__((visibility("default"))) |
46 | 46 | #endif |
47 | 47 |
|
48 | | -// define IECORE_API macro based on whether or not we are compiling IECore, |
49 | | -// or including headers for linking to it. the IECORE_API macro is the one that is |
| 48 | +// When compiling with `-fvisibility=hidden` with GCC or Clang, we run into |
| 49 | +// problems when including 3rd party headers that don't define symbol |
| 50 | +// visibility. Because they don't explicitly assign default visibility to |
| 51 | +// anything, such headers end up inheriting hidden visibility for _everything_. |
| 52 | +// This is particularly problematic if we wish to build template classes around |
| 53 | +// those 3rd party types, because if they are hidden, GCC will force our |
| 54 | +// class to be hidden too, no matter how we declare it. For instance, |
| 55 | +// we would be unable to export `TypedData<Imath::V2f>`. We use these macros |
| 56 | +// to push/pop default visibility around such problematic includes. |
| 57 | +#ifdef __GNUC__ |
| 58 | +#define IECORE_PUSH_DEFAULT_VISIBILITY _Pragma( "GCC visibility push(default)" ) |
| 59 | +#define IECORE_POP_DEFAULT_VISIBILITY _Pragma( "GCC visibility pop" ) |
| 60 | +#else |
| 61 | +#define IECORE_PUSH_DEFAULT_VISIBILITY |
| 62 | +#define IECORE_POP_DEFAULT_VISIBILITY |
| 63 | +#endif |
| 64 | + |
| 65 | +// Define IECORE_API macro based on whether or not we are compiling IECore, |
| 66 | +// or including headers for linking to it. The IECORE_API macro is the one that is |
50 | 67 | // used in the class definitions. |
51 | 68 | #ifdef IECORE_EXPORTS |
52 | 69 | #define IECORE_API IECORE_EXPORT |
|
0 commit comments