Partager via


C6306

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

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.

Example

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);  
}  

See Also

C6273