How to fix va_list/va_arg related C error ‘expected expression before int’

Problem:

You have C code like

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

but when you try to compile it you see an error message like

main.c:5:23: error: expected expression before ‘int’
  int mode= va_arg(ap, int);
                       ^~~

Solution:

This error occurs because va_arg is undeclared. Add

#include <stdarg.h>

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