Forum Discussion
Altera_Forum
Honored Contributor
21 years agoPlease read the manual to clear up the confusion.
Below is a paste from the manual which may clear this up. "The ANSI C standard defines a hosted application as one that calls main() to begin execution. At the start of main(), a hosted application presumes the runtime environment and all system services are initialized and ready to use. This presumption is the case with the HAL system library. In fact, the hosted environment is one of the HAL’s greatest benefits to new Nios II programmers, because you don’t have to consider what devices exist in the system or how to initialize each one; the HAL automatically initializes the whole system. The ANSI C standard also provides for an alternate entry point that avoids automatic initialization, and assumes that the Nios II programmer manually initializes any hardware that is used. The alt_main() function provides a free-standing environment, giving you complete control over the initialization of the system. The free-standing environment places upon the programmer the burden of manually initializing any system feature used in the program. For example, calls to printf() do not function correctly in the free-standing environment, unless alt_main() first instantiates a character-mode device driver, and redirects stdout to the device." In summary if you don't understand what alt_main is you probably should not be using it.