# V1107. Function was declared as accepting unspecified number of parameters. Consider explicitly specifying the function parameters list.

The analyzer has detected a function declaration with an unspecified number of parameters and a call to it with a non-zero number of arguments. Such a call may indicate an error in code. Developers may have intended to call another function with a similar name.

In C, you can declare a function with an unspecified number of parameters:

    void foo();

It may appear that a function that takes no parameters is declared, as in C++. However, this is not the case. The following code compiles successfully:

    void foo();

    void bar()
    {
      foo("%d %d %d", 1, 2, 3); // No compiler checks
    }

When declaring the 'foo' function, the programmer could have expected one of the following behavior options.

Option N1. The 'foo' function was not supposed to take parameters, and the compiler should have issued an error. In such a case, if you work with standards prior to C23, the function declaration should contain the explicitly specified 'void' in the parameter list:

    void foo(void);

    void bar()
    {
      foo("%d %d %d", 1, 2, 3); // Compile-time error
    }

Option N2. The 'foo' function is variadic and can take a variable number of parameters. In such a case, explicitly specify an ellipsis ('...') when declaring the function.

    void foo1(const char *, ...); // since C89
    void foo2(...);               // since C23

    void bar()
    {
      foo1("%d %d %d", 1, 2, 3); // ok since C89
      foo2("%d %d %d", 1, 2, 3); // ok since C23
    }

Note. Starting with C23, compilers should treat the following declarations as declarations of functions that do not take any parameters:

    void foo();     // Takes no parameters
    void bar(void); // Takes no parameters

The analyzer is aware of such behavior and does not issue warnings for such declarations since C23.