Skip to main content

IAR Embedded Workbench for RISC-V 3.40

EXP-main-ret-int

In this section:
Synopsis

The return type of main() is not int.

Enabled by default

No

Severity/Certainty

Low/High

lowhigh.png
Full description

The return type of the main function is not int. The main function is expected to return an integer, so that the caller of the application can determine whether the application executed successfully or failed.

Coding standards

This check does not correspond to any coding standard rules.

Code examples

The following code example fails the check and will give a warning:

void main() { };  //main does not return an int

The following code example passes the check and will not give a warning about this issue:

int main() {return 1;}  //OK - main returns an int