Versions Compared

Key

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

Wiki Markup
Calling a function with incorrect arguments can result in unexpected or unintended program behavior. Functions that are appropriately declared \[[DCL07-A. Include the appropriate type information in function declarators]\] will fail compilation if they are supplied with the wrong number or types of arguments. However, there are cases where supplying the incorrect arguments to a function will only generate compiler warnings. These warnings should be resolved \[[MSC00-A. Compile cleanly at high warning levels]\], but do not prevent program compilation.

Non-Compliant Code Example: (function pointers)

Code Block
bgColor#FFCCCC

#include <stdio.h>
extern char *strchr();

char *(*fp) ();

int main(void) {  
  char *c;
  fp = strchr;
  c = fp(12,2);
  printf("%s\n",c);

}

Compliant Solution: (function pointers)

Code Block
bgColor#ccccff


extern char *strchr();

char *(*fp) ();

int main(void) {  
  char *c;
  fp = strchr;
  c = fp(12,2);
  printf("%s\n",c);

}

Non-Compliant Code Example: (variadic functions)

Wiki Markup
The POSIX function {{open()}} \[[Open Group 04|AA. C References#Open Group 04]\] is a variadic function with the following prototype:

...