How to fix C warning ‘implicit declaration of function va_arg’

Problem:

You have C code like

va_list ap;
int mode = va_arg(ap, int);

but when you try to compile it you see a warning message like

main.c:5:12: warning: implicit declaration of function ‘va_arg’ [-Wimplicit-function-declaration]
  int mode= va_arg(ap, int);

Solution:

Add

#include <stdarg.h>

at the top of the source file where the error occured. This will include the definitions for both va_list and va_arg.