Hello,
mingw.h defines a preprocessor macro main(), so that it can wrap the
original function and hoook into initialization.
The real main() function can have different types of its second
parameter (char**, const char**, char*[]). It is not easy to match
the type and gcc issues a const warning. My patch fixes that.
There were solutions for the same issue published ([1], [2]), but
none of them appeared in junio/pu. This new solution should be more
future proof, as it modifies only compat/mingw.h; the *.c files can
have any of the types mentioned above.
I promise to take care of the integration into msysGit if this patch
gets accepted. To make it easier, I'm submitting a patch that has
been part of msysGit for 3 years.
Karsten Blees (1):
Win32: move main macro to a function
Stepan Kasal (1):
mingw: avoid const warning
compat/mingw.c | 15 +++++++++++++++
compat/mingw.h | 17 ++++++-----------
2 files changed, 21 insertions(+), 11 deletions(-)
--
1.9.2.msysgit.0.496.g23aa553
[1] a hack to fix the warning, by Pat Thoyts, in msysGit since
1.8.5.2.msysgit.0 (Dec 2013):
https://github.com/msysgit/git/commit/6949537a
[2] more elgant fix:
From: Marat Radchenko <redacted>
Date: Tue, 29 Apr 2014 13:12:02 +0400
http://article.gmane.org/gmane.comp.version-control.git/247535
--
--
*** 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.
From: Karsten Blees <redacted>
Date: Fri, 7 Jan 2011 19:47:23 +0100
The code in the MinGW main macro is getting more and more complex, move to
a separate initialization function for readabiliy and extensibility.
Signed-off-by: Karsten Blees <redacted>
Signed-off-by: Erik Faye-Lund <redacted>
Signed-off-by: Stepan Kasal <redacted>
---
compat/mingw.c | 15 +++++++++++++++
compat/mingw.h | 14 ++++----------
2 files changed, 19 insertions(+), 10 deletions(-)
@@ -1847,3 +1847,18 @@ int mingw_offset_1st_component(const char *path)returnoffset+is_dir_sep(path[offset]);}++voidmingw_startup()+{+/* copy executable name to argv[0] */+__argv[0]=xstrdup(_pgmptr);++/* initialize critical section for waitpid pinfo_t list */+InitializeCriticalSection(&pinfo_cs);++/* set up default file mode and file modes for stdin/out/err */+_fmode=_O_BINARY;+_setmode(_fileno(stdin),_O_BINARY);+_setmode(_fileno(stdout),_O_BINARY);+_setmode(_fileno(stderr),_O_BINARY);+}
--
1.9.2.msysgit.0.496.g23aa553
--
--
*** 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.
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 *[]".
Signed-off-by: Stepan Kasal <redacted>
---
compat/mingw.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--
1.9.2.msysgit.0.496.g23aa553
--
--
*** 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.
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.
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.