在 2024-04-19 15:37, Martin Storsjö 写道:
-  _CRTIMP int __cdecl execvpe(const char *_Filename,char *const
_ArgList[],char *const _Env[]) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
+  _CRTIMP int __cdecl execv(const char *_Filename,const char *const
_ArgList[]) __MINGW_ATTRIB_DEPRECATED_MSVC2005;

Thanks, I think this patch is correct, so I think we should apply it.

However, this is a quite subtle area, and this can actually cause breakage in 
user code.

The conversion from `char**` to `const char* const*` is only implicit in C++, and not in C. The POSIX prototypes have only one `const` [1].

The Microsoft variants do have double `const` [2], so I think the proposed patch may be acceptable, as long as users have been aware of that.


[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
[2] 
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/execve-wexecve?view=msvc-170


   $ cat test.c
   void use(const char* const* pp);
   void pass(char** pp) { use(pp);  }

   $ gcc -fsyntax-only -W{all,extra,pedantic} test.c
   test.c: In function ‘pass’:
test.c:2:28: warning: passing argument 1 of ‘use’ from incompatible pointer type [-Wincompatible-pointer-types]
       2 | void pass(char** pp) { use(pp);  }
         |                            ^~
         |                            |
         |                            char **
   test.c:1:29: note: expected ‘const char * const*’ but argument is of type 
‘char **’
       1 | void use(const char* const* pp);
         |          ~~~~~~~~~~~~~~~~~~~^~



--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to