Bug #413
closedmain() needs to return int
Description
=begin
According to the C standard, main always needs to be declared to return an int and can take zero or two parameters. It can officially have two declarations:
int main(void)
int main(int, char **)
The attached patch adds the int return to places where it is missing and uses the more portable two parameter declaration for main. It is against the ruby_1_8_6 branch in svn.
=end
Files
Updated by shyouhei (Shyouhei Urabe) about 16 years ago
=begin
No, not really.
Fact (1)
When abbreviated, a function's return value defaults to int. So,
main(int, char*);
is a 100% conforming declaration of main function for C89.
Fact (2)
IEEE Std 1003.1 says in its rationale:
"Implementations are required to support the two-argument calling
sequence, but this does not prohibit an implementation from
supporting envp as an optional third argument."
So optional third argument of main is not a bad habit.
=end
Updated by pzb (Peter Bowen) about 16 years ago
=begin
On (1), the return value defaulting to int was removed in C99 (ISO/IEC 9899:1999). If the target for ruby is C89/C90, then this is fine.
Fair enough on (2).
I'm mostly trying to clean out some out of tree patches that we have been carrying around. I will take this as a reject and drop the patch.
=end
Updated by nobu (Nobuyoshi Nakada) about 16 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r18459.
=end
Updated by nobu (Nobuyoshi Nakada) about 16 years ago
=begin
Hi,
At Sat, 9 Aug 2008 11:03:13 +0900,
Shyouhei Urabe wrote in [ruby-core:18213]:
So optional third argument of main is not a bad habit.
That envp was used in 0.95 but it hasn't been used in 1.0
already. Seems to no longer need to be there.
--
Nobu Nakada
=end