Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFCCCC
function(1, 2);
...
voidint functionfunc(int one, int two, int three){
  printf("args%d %d %d $d", one, two, three);
  return 1;
}

Solution: Use function prototypes at the top of .c file or in a .h file so that a compiler error will occur if an incorrect number of arguments are used.

Compliant Solution

Code Block
bgColor#ccccff
voidint function(int one, int two, int three); //at top of file or in .h file
...
function(1,2); //compiler error
...
int func(int one, int two, int three){
  printf("%d %d %d", one, two, three);
  return 1;
}

Also using a compiler setting that checks for implicity declared function will prevent accidentally calling a function before it is declared.

...