Edit

Share via


Warning C6306

Incorrect call to 'function': consider using 'function' which accepts a va_list as an argument

Remarks

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

Code analysis name: INCORRECT_VARARG_FUNCTIONCALL

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 C6306
   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