C / C++ FAQs & Programming Resources - ProkutFAQ : CMain

HomePage Recent Changes Recently Commented Login/Register
Quick Links
Categories
Links

Is the main function a must in a program?

It depends on the environment your program is written for. If its a hosted environment, then main function is a must for any standard C/C++ program. Hosted environments are those where there is full support of standard libraries and the main function is a must . Freestanding environment are those where the program may have non-standard startup/exit mechanisms and need not have full support for standard libraries, and so the main function is not required in freestanding environments. Usually only a limited number of I/O libraries will be supported and no memory management functions will be supported in freestanding environments. Examples of freestanding implementations are embedded systems and the operating system kernel.

References

Freestanding and hosted environments - C book article
 Comments [Hide comments/form]
Page was generated in 0.0197 seconds