GCC default main return value is not zero

前端 未结 1 946
说谎
说谎 2021-01-17 16:02

I have some C programs without any explicit return from main, like this:

int main(int argc, char *argv[])
{
  // blah blah
}

If I compile the

相关标签:
1条回答
  • 2021-01-17 16:47

    By default gcc is -std=gnu89 which is C90 + GNU extensions.

    And C90 says:

    (C90, 5.1.2.2.3) "If the main function executes a return that specifies no value, the termination status returned to the host environment is undefined"

    Compiles with -std=c99 or -std=gnu99 to have a return value of 0 when return is omitted in main function.

    0 讨论(0)
提交回复
热议问题