Re: [PATCH 6/6] sparse: Fix mingw_main() argument number/type errors

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 6/6] sparse: Fix mingw_main() argument number/type errors

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:03

René Scharfe [off-list ref] writes:
quoted hunk
Why not take the opposite direction with a patch like this?
...
diff --git a/compat/mingw.h b/compat/mingw.h
index 389ae01..74e7b87 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -452,11 +452,11 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen);
 
 void mingw_startup();
 #define main(c,v) dummy_decl_mingw_main(); \
-static int mingw_main(); \
+static int mingw_main(int, const char **); \
 int main(int argc, const char **argv) \
But traditionally main is declared like 

	int main(int argc, char *argv[]);

without const, no?

Re: [PATCH 6/6] sparse: Fix mingw_main() argument number/type errors

From: René Scharfe <hidden>
Date: 2016-06-15 22:57:03

Am 28.04.2013 21:31, schrieb Junio C Hamano:
René Scharfe [off-list ref] writes:
quoted
Why not take the opposite direction with a patch like this?
...
diff --git a/compat/mingw.h b/compat/mingw.h
index 389ae01..74e7b87 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -452,11 +452,11 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen);

  void mingw_startup();
  #define main(c,v) dummy_decl_mingw_main(); \
-static int mingw_main(); \
+static int mingw_main(int, const char **); \
  int main(int argc, const char **argv) \
But traditionally main is declared like

	int main(int argc, char *argv[]);

without const, no?
Yes, http://c-faq.com/ansi/maindecl.html and basically everybody else 
agree.  Now that I actually think about it, the only benefit of 
declaring argv constant I can find is that the const'ness could easily 
spread to other variables and function arguments where it may actually 
matter.  So please ignore my interjection.  Or perhaps it might be worth 
mentioning in the commit message that removal of that "const" improves 
the code's standard compliance.

René

Re: [PATCH 6/6] sparse: Fix mingw_main() argument number/type errors

From: Ramsay Jones <hidden>
Date: 2016-06-15 22:57:04

René Scharfe wrote:
Am 28.04.2013 21:31, schrieb Junio C Hamano:
quoted
René Scharfe [off-list ref] writes:
quoted
Why not take the opposite direction with a patch like this?
...
diff --git a/compat/mingw.h b/compat/mingw.h
index 389ae01..74e7b87 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -452,11 +452,11 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen);

  void mingw_startup();
  #define main(c,v) dummy_decl_mingw_main(); \
-static int mingw_main(); \
+static int mingw_main(int, const char **); \
  int main(int argc, const char **argv) \
But traditionally main is declared like

	int main(int argc, char *argv[]);

without const, no?
Yes, http://c-faq.com/ansi/maindecl.html and basically everybody else 
agree.  Now that I actually think about it, the only benefit of 
declaring argv constant I can find is that the const'ness could easily 
spread to other variables and function arguments where it may actually 
matter.  So please ignore my interjection.  Or perhaps it might be worth 
mentioning in the commit message that removal of that "const" improves 
the code's standard compliance.
Hmm, well, strictly speaking, I can't say that is true! (see previous
email). It is certainly true that it more closely follows the *spirit*
of the standard, if not the letter of the law.

ATB,
Ramsay Jones
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help