Is implicit function declaration legal in C89?

后端 未结 2 2047
青春惊慌失措
青春惊慌失措 2020-12-17 05:12

Consider this C program:

int main()
{
    puts(\"Hello world!\");
    return 0;
}

This compiles and runs fine and as far as I understand, i

2条回答
  •  有刺的猬
    2020-12-17 05:43

    Is implicit function declaration legal in C89?

    Yes. From section 3.3.2.2:

    If the expression that precedes the parenthesized argument list in a function call consists solely of an identifier, and if no declaration is visible for this identifier, the identifier is implicitly declared exactly as if, in the innermost block containing the function call, the declaration

        extern int  identifier();
    

    appeared.

提交回复
热议问题