From: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
To: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
Cc: Junio C Hamano <gitster@pobox.com>,
GIT Mailing-list <git@vger.kernel.org>
Subject: Re: [PATCH 6/6] sparse: Fix mingw_main() argument number/type errors
Date: Mon, 29 Apr 2013 22:52:45 +0100 [thread overview]
Message-ID: <517EEBAD.3090201@ramsay1.demon.co.uk> (raw)
In-Reply-To: <517C6DEF.2050305@lsrfire.ath.cx>
René Scharfe wrote:
> Am 27.04.2013 21:19, schrieb Ramsay Jones:
>> In order to suppress these warnings, since both of the main
>> functions need to be declared with the same prototype, we
>> change the declaration of the 9 main functions, thus:
>>
>> int main(int argc, char **argv)
>
> Why not take the opposite direction with a patch like this? It's quick
> and dirty and based on v1.8.1.msysgit.1, as that was the version I had
> lying around here, but you get the idea.
The main reason (99%) was patch size. I only noticed a "recent trend"
to declare the main() with a 'const char **argv' parameter because,
over the years, I've had to keep adding to this patch. (Having said
that, I suspect it has only been about four additions in four years).
The other 1% is simply that it just looks wrong! (yeah, this new
'const' thingamajig has it's uses, but still ... :-D ).
Just FYI, the C99 standard has this to say:
c99 standard 5.1.2.2.1 "Program startup"
The function called at program startup is named main. The
implementation declares no prototype for this function. It
shall be defined with a return type of int and with no
parameters:
int main(void) { /* ... */ }
or with two parameters (referred to here as argc and argv,
though any names may be used, as they are local to the
function in which they are declared);
int main(int argc, char *argv[]) { /* ... */ }
or equivalent;^9 or in some other implementation-defined
manner.
[note 9: Thus, int can be replaced by a typedef name
defined as int, or the type of argv can be written as
char **argv, and so on.]
...
- The parameters argc and argv and the strings pointed
to by the argv array shall be modifiable by the program,
and retain their last-stored values between program
startup and program termination.
That "... or in some other implementation-defined manner." tends
to make this text somewhat weak!
ATB,
Ramsay Jones
prev parent reply other threads:[~2013-04-29 23:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-27 19:19 [PATCH 6/6] sparse: Fix mingw_main() argument number/type errors Ramsay Jones
2013-04-28 0:31 ` René Scharfe
2013-04-28 19:31 ` Junio C Hamano
2013-04-29 16:10 ` René Scharfe
2013-04-29 23:30 ` Ramsay Jones
2013-04-29 21:52 ` Ramsay Jones [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=517EEBAD.3090201@ramsay1.demon.co.uk \
--to=ramsay@ramsay1.demon.co.uk \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=rene.scharfe@lsrfire.ath.cx \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.