On Thursday 18 December 2025 06:05:00 Kirill Makurin wrote:
> This patch removes inline and macro definitions of str[n]casecmp from 
> string.h. Both str[n]casecmp already defined as aliases for CRT's _str[n]icmp 
> in crt-aliases.def.in.
> 
> In general, I would like to look more through mingw-w64's header files and 
> remove such definitions wherever possible. I think we should avoid providing 
> inline definitions for functions which are not provided by CRTs, since 
> applications may want to define functions with these names (even if those are 
> POSIX names, since Windows is not POSIX it should be allowed).
> 
> Results of GitHub CI for this single patch are here[1].
> 
> - Kirill Makurin
> 
> [1] https://github.com/maiddaisuki/mingw-w64/actions/runs/20323047405

> From 4559b4cbc92f59111cb8a08182b8d2b57f059654 Mon Sep 17 00:00:00 2001
> From: Kirill Makurin <[email protected]>
> Date: Thu, 18 Dec 2025 10:32:03 +0900
> Subject: [PATCH 1/9] crt: remove inline definitions of str[n]casecmp from
>  string.h
> 
> mingw-w64 already defines str[n]casecamp as an alias for
> _str[n]icmp in crt-aliases.def.in. There is no need to define
> them as inline wrappers or override them through macros.
> 
> Removing inline definition from string.h also allows other
> packages to define functions named str[n]casecmp.
> 
> Signed-off-by: Kirill Makurin <[email protected]>
> ---
>  mingw-w64-headers/crt/string.h | 7 -------
>  1 file changed, 7 deletions(-)
> 
> diff --git a/mingw-w64-headers/crt/string.h b/mingw-w64-headers/crt/string.h
> index 1832e38ed..e947930ff 100644
> --- a/mingw-w64-headers/crt/string.h
> +++ b/mingw-w64-headers/crt/string.h
> @@ -126,13 +126,6 @@ extern "C" {
>    int __cdecl strnicmp(const char *_Str1,const char *_Str,size_t _MaxCount) 
> __MINGW_ATTRIB_DEPRECATED_MSVC2005;
>    int __cdecl strncasecmp (const char *, const char *, size_t);
>    int __cdecl strcasecmp (const char *, const char *);
> -#ifndef __CRT__NO_INLINE
> -  __CRT_INLINE int __cdecl strncasecmp (const char *__sz1, const char 
> *__sz2, size_t __sizeMaxCompare) { return _strnicmp (__sz1, __sz2, 
> __sizeMaxCompare); }
> -  __CRT_INLINE int __cdecl strcasecmp (const char *__sz1, const char *__sz2) 
> { return _stricmp (__sz1, __sz2); }
> -#else
> -#define strncasecmp _strnicmp
> -#define strcasecmp _stricmp
> -#endif /* !__CRT__NO_INLINE */

Together with removing those inline functions and macro redefinitions,
it would be good to add __MINGW_ASM_CALL for strncasecmp and strcasecmp
to have redirects to _strnicmp and _stricmp like it was before this
change.

Otherwise this change cause that PE IMPORT TABLE generated by GNU LD
would have duplicate entries when both strcasecmp and _stricmp are used
by applications.

>    char *__cdecl strnset(char *_Str,int _Val,size_t _MaxCount) 
> __MINGW_ATTRIB_DEPRECATED_MSVC2005;
>    char *__cdecl strrev(char *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
>    char *__cdecl strset(char *_Str,int _Val) 
> __MINGW_ATTRIB_DEPRECATED_MSVC2005;
> -- 
> 2.51.0.windows.1
> 


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

Reply via email to