Quote from 3.6.1/1 N3797:
A program shall contain a global function called main, which is the designated start of the program. It is implementation-defined whether a program in a freestanding environment is required to define a main function.
Are "a program" and "a program in a freestanding environment" different things?
C++ is often used in embedded systems programming. There you might encounter a(n example of) lack of "host environment" in which case you're running in a free standing evironment.
What this practically means is that, apart from lack of OS I/O, threading etc libraries is that some facilities are unavailable and it requires assembly start-up code to get you to main(); Characteristic differences (just to get an idea) are
Exceptions require code to unwind the stack while looking for an appropriate exception handler to handle the exception. Usually, this code is linked in with your C++ application, but in a freestanding kernel the code must be provided manually.
You'd have to write your own heap manager (new/delete) if you wanted to create objects at runtime and your own scheduler if you wanted more than one thread
So considerations, techniques and application domain may vary but a program is a program.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With