MinGW: Add dllimport/dllexport attributes when compiling with clang

The GCC compiler will automatically export all symbols on MinGW, but this is not the case for clang.  Add the `__declspec` attributes when compiling with clang on MinGW.
This commit is contained in:
Frederik Carlier 2024-01-12 13:21:20 +01:00
parent a0ce4ab880
commit c1d982a854

View file

@ -381,9 +381,10 @@ static inline void gs_consumed(id NS_CONSUMED GS_UNUSED_ARG o) { return; }
#if defined(GNUSTEP_WITH_DLL) #if defined(GNUSTEP_WITH_DLL)
#if BUILD_libgnustep_base_DLL #if BUILD_libgnustep_base_DLL
# if defined(__MINGW__) # if defined(__MINGW__) && !defined(__clang__)
/* On Mingw, the compiler will export all symbols automatically, so /* On Mingw, the GCC compiler will export all symbols automatically, so
* __declspec(dllexport) is not needed. * __declspec(dllexport) is not needed. Clang uses the more standard behavior,
* requiring you to add add a dllimport/dllexport attribute.
*/ */
# define GS_EXPORT_CLASS # define GS_EXPORT_CLASS
# define GS_EXPORT extern # define GS_EXPORT extern
@ -396,8 +397,8 @@ static inline void gs_consumed(id NS_CONSUMED GS_UNUSED_ARG o) { return; }
# define GS_DECLARE __declspec(dllexport) # define GS_DECLARE __declspec(dllexport)
# endif # endif
#else #else
# if defined(__MINGW__) # if defined(__MINGW__) && !defined(__clang__)
/* MinGW does not need dllimport on ObjC classes and produces warnings. */ /* On MinGW, the GCC compiler does not need dllimport on ObjC classes and produces warnings. */
# define GS_EXPORT_CLASS # define GS_EXPORT_CLASS
# else # else
# define GS_EXPORT_CLASS __declspec(dllimport) # define GS_EXPORT_CLASS __declspec(dllimport)