Good point. I am not sure if they would actually accept it. Never tried
it.
However it is incorrect as it implies main can return which it can't.
No more than void main(). void says that it doesn't return a value, not
that it can't return.
In pre-standard times int was the return type used for functions that
didn't return a value.
In many situations a return from main is fatal.
In a free-standing system it would be as incorrect to use int main as it
is to use void main in a hosted environment.
Not at all. It is a well established practice in C (for better or worse)
of ignoring returned values.
Though there is less harm
in using void main in a hosted environment.
Using void main() in a hosted environment has undefined behaviour, int
main is really much the same as void main in a freestanding enviroment,
except that it might be returning a value that is ignored. Of course it
depends on the forms of startup function the freestanding implementation
supports, you need to use whatever is defined.
The int return in a hosted system is stylistic. There is often nothing
returned so having a void makes no difference. If you do need to return
something then you have to put it in.
Writing void main is simply not valid in a hosted environment, void isn't
a return type for main that C supports. So this isn't a stylistic thing is
is a correctness thing.
In a free-standing system having a return the implication is that the
program could terminate.
It is a weak implication, if you know it doesn't then it doesn't.
This is not something you want to have even as
a fleeting thought. Many free standing systems are embedded systems and
safety critical.
void main() doesn't imply that main() doesn't return.
Personally I would never write a hosted application without the int
return but I would never put a return type other than void on a free-
standing system.
That assumes that the freestanding implementation gives you the choice.
Lawrence