Hmm, as all of those are functions, and we get those warnings during
crt build. So we could simply take care that within crt build (and it
helper libraries) those prototypes using a _CRTIMP variant without
dllimport.

This should work in all scenarios well, as linker will resolve such functions.

Regards,
Kai

2016-08-22 11:04 GMT+02:00 David Wohlferd <[email protected]>:
> On 8/18/2016 11:27 PM, David Wohlferd wrote:
>> 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).
>
> Below is the list of functions that have the problem.  Note most are in
> secapi.
>
> .../mingw-w64-crt/misc/invalid_parameter_handler.c:21:36: warning:
> '_get_invalid_parameter_handler' redeclared without dllimport attribute:
> previous dllimport ignored [-Wattributes]
> .../mingw-w64-crt/misc/invalid_parameter_handler.c:22:36: warning:
> '_set_invalid_parameter_handler' redeclared without dllimport attribute:
> previous dllimport ignored [-Wattributes]
> .../mingw-w64-crt/misc/purecall.c:10:27: warning:
> '_set_purecall_handler' redeclared without dllimport attribute: previous
> dllimport ignored [-Wattributes]
> .../mingw-w64-crt/secapi/_controlfp_s.c:14:17: warning: '_controlfp_s'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
> .../mingw-w64-crt/secapi/_ctime32_s.c:7:17: warning: '_localtime32_s'
> redeclared without dllimport attribute after being referenced with dll
> linkage
> .../mingw-w64-crt/secapi/_ctime32_s.c:8:17: warning: 'asctime_s'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
> .../mingw-w64-crt/secapi/_ctime32_s.c:9:17: warning: '_ctime32_s'
> redeclared without dllimport attribute after being referenced with dll
> linkage
> .../mingw-w64-crt/secapi/_ctime64_s.c:7:17: warning: '_localtime64_s'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
> .../mingw-w64-crt/secapi/_ctime64_s.c:8:17: warning: 'asctime_s'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
> .../mingw-w64-crt/secapi/_gmtime32_s.c:8:17: warning: '_gmtime32_s'
> redeclared without dllimport attribute after being referenced with dll
> linkage
> .../mingw-w64-crt/secapi/_gmtime64_s.c:8:17: warning: '_gmtime64_s'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
> .../mingw-w64-crt/secapi/_localtime32_s.c:8:17: warning:
> '_localtime32_s' redeclared without dllimport attribute after being
> referenced with dll linkage
> .../mingw-w64-crt/secapi/_localtime64_s.c:8:17: warning:
> '_localtime64_s' redeclared without dllimport attribute: previous
> dllimport ignored [-Wattributes]
> .../mingw-w64-crt/secapi/_sopen_s.c:6:17: warning: '_sopen_s' redeclared
> without dllimport attribute: previous dllimport ignored [-Wattributes]
> .../mingw-w64-crt/secapi/_wasctime_s.c:7:17: warning: '_wasctime_s'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
> .../mingw-w64-crt/secapi/_wctime32_s.c:7:17: warning: '_localtime32_s'
> redeclared without dllimport attribute after being referenced with dll
> linkage
> .../mingw-w64-crt/secapi/_wctime32_s.c:8:17: warning: '_wasctime_s'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
> .../mingw-w64-crt/secapi/_wctime32_s.c:9:17: warning: '_wctime32_s'
> redeclared without dllimport attribute after being referenced with dll
> linkage
> .../mingw-w64-crt/secapi/_wctime64_s.c:7:17: warning: '_localtime64_s'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
> .../mingw-w64-crt/secapi/_wctime64_s.c:8:17: warning: '_wasctime_s'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
> .../mingw-w64-crt/secapi/_wctime64_s.c:9:17: warning: '_wctime64_s'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
> .../mingw-w64-crt/secapi/asctime_s.c:7:17: warning: 'asctime_s'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
> .../mingw-w64-crt/secapi/memcpy_s.c:6:17: warning: 'memcpy_s' redeclared
> without dllimport attribute: previous dllimport ignored [-Wattributes]
> .../mingw-w64-crt/secapi/memmove_s.c:6:17: warning: 'memmove_s'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
> .../mingw-w64-crt/secapi/strerror_s.c:7:17: warning: 'strerror_s'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
> .../mingw-w64-crt/stdio/mingw_lock.c:35:14: warning: '_lock_file'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
> .../mingw-w64-crt/stdio/mingw_lock.c:75:14: warning: '_unlock_file'
> redeclared without dllimport attribute: previous dllimport ignored
> [-Wattributes]
>
> dw
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Mingw-w64-public mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

------------------------------------------------------------------------------
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to