Keil Logo

Entering and exiting programs linked with microlib

2.7 Entering and exiting programs linked with microlib

Microlib requires a main() function that takes no arguments and never returns.

Use main() to begin your program. Do not declare main() to take arguments. Microlib does not support command-line arguments from an operating system.
Your program must not return from main(). This is because microlib does not contain any code to handle exit from main(). Microlib does not support programs that call exit().
You can ensure that your main() function does not return, by inserting an endless loop at the end of the function. For example:
void main()
{
  ...
  while (1); // endless loop to prevent return from main()
}
Non-ConfidentialPDF file icon PDF versionARM DUI0378H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.