Why can't I return bigger values from main function?

后端 未结 3 1398
滥情空心
滥情空心 2020-12-09 16:28

I am trying to return a bigger value like 1000 from my main function, but when I type echo $? it displays 0.

If I return a smaller value like 100 it dis

3条回答
  •  长情又很酷
    2020-12-09 16:57

    In Unix-land the return value of main is limited because exit there is limited to the range of an 8-bit byte.

    In Windows there is a single value, STILL_ACTIVE with value 259, that is best avoided as process exit code.

    Other than that, in Windows you can return a 32-bit code such as an HRESULT and that is commonly done.

提交回复
热议问题