Is it possible to exclude a keyword in a return statement?

I recently met the following code snippet in this Apache Axis tutorial example.

int main()
{
    int status = AXIS2_SUCCESS;

    axutil_env_t *env = NULL;
    axutil_allocator_t *allocator = NULL;
    env = create_environment();

    status = build_and_serialize_om(env);

    (status == AXIS2_FAILURE)
    {
        printf(" build AXIOM failed");
    }

    axutil_env_free(env);

     0;
}

What I do not understand is 0;at the end.
Is this a return statement without the return keyword?

I tried the following code snippet to test this in Visual Studio.

int main()
{
    0; // in the second run, replaced 0 with 28
}

Both programs worked without problems. But echo %ERRORLEVEL%at, the window command line returned 0 for both.

But below is a code snippet

int add()
{
    0;
}

causes

Error 1 Error C4716: "Add": should return a value

I understand that the return value is 0implicitly added to main().

I have no problem, including the return keyword, but I'm porting the Axis2 / C library to a C ++ project. And there are many examples where I came across0;

undefined?

+4
2

++ return main(), , void, . main() 0. 0; , no-op, .

+9

? , , , - - - ?

( https://github.com/bnoordhuis/axis2-c/blob/master/axiom/test/util/axiom_util_test.c):

int main()
{
    int status = AXIS2_SUCCESS;
    axutil_env_t *env = NULL;
    status = build_and_serialize_om(env);

    if(status == AXIS2_FAILURE)
    {
        printf(" build AXIOM failed");
    }

    axutil_env_free(env);
    return 0;
}
+2

Source: https://habr.com/ru/post/1617369/


All Articles