I noticed "Avoid void main()" tip in tip page has a hard time earning good points. Tell me, who didn't vote 5 for that - why is void main() good?
I noticed "Avoid void main()" tip in tip page has a hard time earning good points. Tell me, who didn't vote 5 for that - why is void main() good?
Where is this page?
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
Could it be this one? I suppose one might give it a low rating due to lack of elaboration, since it basically shifts the work to an external website.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Tips can be found at the www.cprogramming.com page, along the left.
void main() might work for you but that shouldn't matter. main() always returns an int. Thread over.
Thanks.
Anyways, that and probably the fact that it's beating on a dead horse.
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
Dead horse - you mean noone really is using void main()?
I am frustrated to see tons of examples in the net which use void main().
I tend to shake my head and sigh rather than get frustrated.I am frustrated to see tons of examples in the net which use void main().
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Dead horse in the sense this issue has been beaten to death.Originally Posted by maxorator
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
Look, see it this way...
That's not a tip. It's a language feature assessment. I would give it a 0 rating. I could write a tip to tell people not to use a return statement inside a function that returns void. Some compilers issue a warning. Others don't even bother. Probably only a handful (if any) make that an error even with -pedantic on. However, I would really be just stating the obvious. As with the void main() thing.
A tip should answer the "how", really.
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
How not to use void main? I'd rather the why than the how.
The why is answered on the standards, programming books and articles.
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
The compilers I use return an int regardless of how you declare main(). For example in the code below the compiler will return a pointer to the text as an integer. Of course that integer pointer is useless outside the program but it works anyway.
Code:char* main() { return "Hello"; }
MinGW returns an error (hurray!) on T main() even without -Wall, -Wextra and -pedantic when T is not int.
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
The T made me try a function template:MinGW returns an error (hurray!) on T main() even without -Wall, -Wextra and -pedantic when T is not int.
But of course it didnt work, Comeau C++ reports that "main" is not a valid name for a function template. Silly me.Code:template <typename T> T main() { return T(); } main<int>();
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)