C Language main()

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

C Language main()

598件の閲覧回数
QJ_HAPPY
Contributor I

Why is the endless loop in the main function is :

for (;;)
{
if (exit_code != 0)
break;
}
return exit_code;

and What causes exit_code = -1?

0 件の賞賛
返信
2 返答(返信)

585件の閲覧回数
JRoberto
NXP TechSupport
NXP TechSupport

Hi @QJ_HAPPY 

The code that you get from the main function is just a template. That you can use or not.

Normally, you want the software of an embedded system to execute constantly and so, an infinite loop can help you there.

Returning different values that 0 like, return 1 or return -1 can mean that function finished returning error. But this is not mandatory and it's just a way to evaluate the execution of a function. Anyway you can give it the meaning you need.

 

Best Regards and Happy Coding!

 

0 件の賞賛
返信

517件の閲覧回数
QJ_HAPPY
Contributor I
Thank you for your timely reply. I want to know why I will return - 1 error. Generally, 0 should not be returned if there is no error
0 件の賞賛
返信