C6306

 

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

warning C6306: incorrect call to <function>: consider using <function> which accepts a va_list as an argument

This warning indicates an incorrect function call. The printf family includes several functions that take a variable list of arguments; however, these functions cannot be called with a va_list argument. There is a corresponding vprintf family of functions that can be used for such calls. Calling the wrong print function will cause incorrect output.

The following code generates this warning:

#include <stdio.h>  
#include <stdarg.h>  
  
void f(int i, ...)  
{  
   va_list v;  
  
   va_start(v, i);  
   //code...  
   printf("%s", v); // warning 6306   
   va_end(v);  
}  

To correct this warning, use the following code:

#include <stdio.h>  
#include <stdarg.h>  
  
void f(int i, ...)  
{  
   va_list v;  
  
   va_start(v, i);  
   //code...  
   vprintf_s("%d",v);  
   va_end(v);  
}  

C6273

Show: