Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

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);
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.