win32/win32.c currently generates warnings under gcc.  The problem is 
reproduced by:

#include <process.h>
int main() {
    const char *cmdname;
    const char *const *argv;
    return execv(cmdname, (char *const *)argv);
}

which causes gcc to complain:

test.c:5: warning: passing arg 2 of `execv' from incompatible pointer type

In MinGW (and VC++) execv's 2nd arg is const char *const *, so simply 
removing the cast makes it happy.  However, in Borland C execv's 2nd arg 
is just char * const * (hence the reason for the cast in the first place 
-- must have been written by a Borland C user!), so removing the cast 
makes bcc32 complain:

Warning W8075 test.c 5: Suspicious pointer conversion in function main

How can I keep both compilers (gcc and bcc32) happy?  Is #ifdef hell the 
only way, e.g.

#ifdef __BORLANDC__
    return execv(cmdname, (char *const *)argv);
#else
    return execv(cmdname, argv);
#endif

Why does gcc complain in the first place, though?  I thought that 
passing a non const arg to a function with a const parameter was 
generally not a problem, and indeed, VC++ didn't complain.  What is 
gcc's problem?



------------------------------------------------
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.

Reply via email to