Yitzchak Scott-Thoennes wrote: >On Thu, Jun 30, 2005 at 09:33:50AM +0100, Steve Hay wrote: > > > >>Are you suggesting that I should write >> >>#ifdef __MINGW__ >> return execv(cmdname, argv); >>#else >> return execv(cmdname, (char *const *)argv); >>#endif >> >>? I can't see that that is an improvement because it now applies the >>cast in the VC++ case too, which doesn't need a cast since it has the >>correct prototype to start with. >> >> > >I thought from what you said that it doesn't warn, so it wouldn't hurt >to pass the args correctly. > > But what do you mean by "correctly"? You seem to be meaning "what SUSv3 says", whereas I would have thought that "correct" for a given compiler is "whatever that compiler's headers say".
You're right that it doesn't hurt (and doesn't warn) to apply the cast in the VC++ case, i.e. make them "correct" in the SUSv3 sense, but the cast is not required w.r.t. VC++'s own header files so it seems silly to do the cast. > > > >>The way I saw it is that it is Borland that gets the prototype wrong and >>hence Borland that needs the cast. >> >> > >Borland has: > >int _RTLENTRY _EXPFUNC execv(const char * __path, char * const * __argv); > >VC+: > >_CRTIMP int __cdecl execv(const char *, const char * const *); > >MinGW: > >_CRTIMP int __cdecl _execv (const char*, const char* const*); > >SUSv3 (http://www.opengroup.org/onlinepubs/009695399/functions/execv.html): > >int execv(const char *path, char *const argv[]); > > >So Borland is the only one of the three that gets it right. > OK, I phrased that very badly; sorry. What I meant was that Borland is the only one whose header file doesn't match what the argument we're passing is, and hence the only one that needs the cast. In the caller (e.g. win32/win32.c line 4069) we have const char * const * argv which (as you've laid out above) exactly matches the declaration given by VC++ and MinGW, so they don't require a cast. Borland is the only one the gives a different declaration, so is the only one requiring a cast. The issue of which compilers give declarations that match SUSv3 (... only Borland) seems to me to be a separate issue, and only really of academic interest. ------------------------------------------------ Radan Computational Ltd. The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.