diff --git a/lib-src/ntlib.c b/lib-src/ntlib.c
index bcbc0064318..ccf827cf526 100644
--- a/lib-src/ntlib.c
+++ b/lib-src/ntlib.c
@@ -20,6 +20,15 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see . */
+/* Temporary workaround for compilation problems with MinGW64 GCC 11.
+ The funky #ifdef's are to avoid warnings about unused macros. */
+#define _GL_ATTRIBUTE_MALLOC
+#define _GL_ATTRIBUTE_DEALLOC_FREE
+#ifdef _GL_ATTRIBUTE_MALLOC
+#endif
+#ifdef _GL_ATTRIBUTE_DEALLOC_FREE
+#endif
+
#include
#include
#include