How to fix C warning 'implicit declaration of function va_arg'
Problem:
You have C code like
main.c
va_list ap;
int mode = va_arg(ap, int);but when you try to compile it you see a warning message like
error_message.txt
main.c:5:12: warning: implicit declaration of function ‘va_arg’ [-Wimplicit-function-declaration]
int mode= va_arg(ap, int);Solution
Add
stdarg_include.c
#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.
Check out similar posts by category:
C/C++, GCC Errors
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow