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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html