Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
C6306
Collapse the table of content
Expand the table of content

C6306

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);
}
Show:
© 2015 Microsoft