exit function

Pages: 12
closed account (E0p9LyTq)
That's an improvement, VS didn't even used to warn about this issue because they didn't want to "break" old code that used this "feature".

I am fully aware of that. But it seems rather backwards thinking to worry about legacy coding when using a specific language standard. Code::Blocks (and the underlying MinGW compiler) errors when trying to compile void main() with a language standard set.
@jlb:
Indeed. GNU describes some conventions:
https://www.gnu.org/software/libc/manual/html_node/Exit-Status.html

Seems more platform than compiler-dependent.
But it seems rather backwards thinking to worry about legacy coding when using a specific language standard.

Maybe but using void main() on DOS/Windows systems goes back before even ANSI C much less C++ and until relativity recently following any standards is fairly new to the Microsoft compilers and in many cases they still insist on their own versions of the "standards". For example depreciating standard functions like scanf() and most of the standard C-string functions.

By the way using the return values from programs is a UNIX feature that wasn't implemented in early versions of DOS and Windows which is why they allowed main() to return void.

Code::Blocks (and the underlying MinGW compiler) errors when trying to compile void main() with a language standard set.

What does Code::Blocks or MinGW have to do with the Microsoft compiler?

Seems more platform than compiler-dependent.

Possibly, but either way it is an implementation detail.
From the C draft standard, N1548 Committee Draft — December 2, 2010, Section 7.22.4.4 The exit function

Subsection 5 reads.
Finally, control is returned to the host environment. If the value of status is zero or
EXIT_SUCCESS, an implementation-defined form of the status successful termination is
returned. If the value of status is EXIT_FAILURE, an implementation-defined form
of the status unsuccessful termination is returned. Otherwise the status returned is
implementation-defined.


As you can see almost everything returned is an implementation detail.
Last edited on
closed account (E0p9LyTq)
What does Code::Blocks or MinGW have to do with the Microsoft compiler?

It shows one compiler, for one aspect of the C++ language, is more language standard compliant. By error flagging non-compliance.

Why bother having standards if they aren't followed?

MS implementation by allowing void main() compile IMO is sloppy.
Topic archived. No new replies allowed.
Pages: 12