From: Karsten Blees Date: Fri, 06 Jun 2014 15:08:06 GMT Subject: Re: [PATCH 2/2] mingw: avoid const warning Message-ID: <5391D956.7050903@gmail.com> In-Reply-To: <20140529104716.GC24021@camelia.ucw.cz> Am 29.05.2014 12:47, schrieb Stepan Kasal: > Fix const warnings in http-fetch.c and remote-curl.c main() where is > argv declared as const. > > The fix should work for all future declarations of main, no matter > whether the second parameter's type is "char**", "const char**", or > "char *[]". I'm 100% in favor of a solution that doesn't restrict main to non-const char**! Thanks. > Signed-off-by: Stepan Kasal > --- > compat/mingw.h | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/compat/mingw.h b/compat/mingw.h > index 15f0c9d..8745d19 100644 > --- a/compat/mingw.h > +++ b/compat/mingw.h > @@ -369,10 +369,11 @@ extern CRITICAL_SECTION pinfo_cs; > void mingw_startup(); > #define main(c,v) dummy_decl_mingw_main(); \ > static int mingw_main(c,v); \ > -int main(int argc, char **argv) \ > +int main(c, char **main_argv_not_used) \ > { \ > + typedef v, **argv_type; \ > mingw_startup(); \ > - return mingw_main(__argc, __argv); \ > + return mingw_main(__argc, (argv_type)__argv); \ > } \ > static int mingw_main(c,v) > I have to admit I had trouble understanding what 'typedef v, **arv_type;' does (looks invalid at first glance), and why you would need main_argv_not_used instead of just main(c,v). So, I'd like to award +10 points for cleverness, but -10 for obscurity ;-) Probably deserves a comment or an explanation in the commit message. A simpler solution that works with all definitions of main() is to cast to void* (tell the compiler all responsibility is on us). I.e.: void mingw_startup(); #define main(c,v) dummy_decl_mingw_main(); \ static int mingw_main(c,v); \ int main(c,v) \ { \ mingw_startup(); \ return mingw_main(__argc, (void *) __argv); \ } \ static int mingw_main(c,v) -- -- *** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free. You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to msysgit@googlegroups.com To unsubscribe from this group, send email to msysgit+unsubscribe@googlegroups.com For more options, and view previous threads, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en --- You received this message because you are subscribed to the Google Groups "msysGit" group. To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout.