Node:too few parameters..., Previous:different type arg, Up:...undeclared (first use in this function)



too few parameters..., too many parameters...

Consider the following program:

#include <stdio.h>

void tweedledee (int a, int b, int c)
{
}

void tweedledum (int a, int b)
{
}


/* To shorten example, not using argp */
int main()
{

  tweedledee (1, 2);
  tweedledum (1, 2, 3);

  return 0;
}

The tweedledee function takes three parameters, but main passes it two, whereas the tweedledum function takes two parameters, but main passes it three. The result is a pair of straightforward error messages:

params.c: In function `main':
params.c:14: too few arguments to function `tweedledee'
params.c:15: too many arguments to function `tweedledum'

This is one reason for the existence of function prototypes. Before the ANSI Standard, compilers did not complain about this kind of error. If you were working with a library of functions with which you were not familiar, and you passed one the wrong number of parameters, the error was sometimes difficult to track. Contemporary C compilers such as GCC that follow the standard make finding parameter mismatch errors simple.