My next patch is very small, but it affects a bunch of code. Ponder it a bit before approving. The goal is to fix all the warnings like this:

warning: '_unlock_file' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]

This occurs because our headers use:

  _CRTIMP void __cdecl _unlock_file(FILE *_File);

and _CRTIMP is always defined like this:

#ifndef _CRTIMP
#define _CRTIMP __declspec(dllimport)
#endif

If we were *only* providing a mapping to the function in a DLL, this would be fine. But we actually create an implementation of this function (mingw-w64-crt/stdio/mingw_lock.c). And the implementation uses the same header. Since it makes no sense to have an implementation tagged as dllimport, I assert that when building mingw-w64, _CRTIMP should always be defined as blank (attached).

dw
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 886fcf0..e52f961 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -20,7 +20,7 @@ else
 endif
 
 AM_CPPFLAGS=-D_CRTBLD $(sysincludes)
-AM_CFLAGS=-pipe -std=gnu99 -D_WIN32_WINNT=0x0f00 @ADD_C_CXX_WARNING_FLAGS@ @ADD_C_ONLY_WARNING_FLAGS@
+AM_CFLAGS=-pipe -std=gnu99 -D_WIN32_WINNT=0x0f00 @ADD_C_CXX_WARNING_FLAGS@ @ADD_C_ONLY_WARNING_FLAGS@ -D_CRTIMP=
 AM_CXXFLAGS=@ADD_C_CXX_WARNING_FLAGS@ @ADD_CXX_ONLY_WARNING_FLAGS@
 CPPFLAGSARM32=-mfpu=vfp
 CPPFLAGS32=-m32
diff --git a/mingw-w64-crt/Makefile.in b/mingw-w64-crt/Makefile.in
index 58c05c2..746d246 100644
--- a/mingw-w64-crt/Makefile.in
+++ b/mingw-w64-crt/Makefile.in
@@ -5092,7 +5092,7 @@ top_srcdir = @top_srcdir@
 @WITHSYSROOT_FALSE@withsys = 
 @WITHSYSROOT_TRUE@withsys = --with-sysroot=@TARGET_SYSTEM_ROOT@
 AM_CPPFLAGS = -D_CRTBLD $(sysincludes)
-AM_CFLAGS = -pipe -std=gnu99 -D_WIN32_WINNT=0x0f00 @ADD_C_CXX_WARNING_FLAGS@ @ADD_C_ONLY_WARNING_FLAGS@
+AM_CFLAGS = -pipe -std=gnu99 -D_WIN32_WINNT=0x0f00 @ADD_C_CXX_WARNING_FLAGS@ @ADD_C_ONLY_WARNING_FLAGS@ -D_CRTIMP=
 AM_CXXFLAGS = @ADD_C_CXX_WARNING_FLAGS@ @ADD_CXX_ONLY_WARNING_FLAGS@
 CPPFLAGSARM32 = -mfpu=vfp
 CPPFLAGS32 = -m32
------------------------------------------------------------------------------
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to