[PATCH] Hide "'dllexport' attribute ignored" warnings on MINGW

Sergey B Kirpichev skir at sagemath.org
Sun Aug 17 16:07:22 CEST 2025


Hello,

could you consider to apply attached patch?  It's used
to build gmpy2 bindings (Python) and for the mingw-w64-gmp.
Else build logs are flooded with warnings like:
 ../gmp-impl.h:4734:3: warning: 'dllexport' attribute ignored [-Wattributes]
   4734 |   DECL_copyd           ((*copyd));

See
https://github.com/aleaxit/gmpy/blob/master/scripts/dll-importexport.diff
https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-gmp/do-not-use-dllimport.diff
-------------- next part --------------
--- gmp-h.in.orig	2025-08-15 13:37:06.328877394 +0300
+++ gmp-h.in	2025-08-15 13:40:01.036262673 +0300
@@ -101,8 +101,13 @@
    make use of that.  Probably more trouble than it's worth.  */

 #if defined (__GNUC__)
+#ifndef __MINGW32__
 #define __GMP_DECLSPEC_EXPORT  __declspec(__dllexport__)
 #define __GMP_DECLSPEC_IMPORT  __declspec(__dllimport__)
+#else
+#define __GMP_DECLSPEC_EXPORT
+#define __GMP_DECLSPEC_IMPORT
+#endif
 #endif
 #if defined (_MSC_VER) || defined (__BORLANDC__)
 #define __GMP_DECLSPEC_EXPORT  __declspec(dllexport)


More information about the gmp-devel mailing list