1

The error shown:

Error   11  error C2664: '_vswprintf_c_l' : cannot convert parameter 4 from 'void *' to '_locale_t' C:\Program Files\Microsoft Visual Studio 8\VC\include\swprintf.inl  41

It locates the file- C:\Program Files\Microsoft Visual Studio 8\VC\include\swprintf.inl which is a system file I guess. So, how to resolve?

Platform: Visual Studio 2005 Version 8.0.50727.762

Gulshan
  • 3,611
  • 5
  • 35
  • 46
  • It sounds like you are forgetting to pass the locale parameter. – leppie Jul 13 '11 at 12:09
  • Is this the complete error message? The mistake is probably in your code. Could you please add the code where the error occurs. If VS doesn't point you to the specific line in your code, it must be in the file that's being compiled someplace where you call _vswprintf_ or a similar function. – Codo Jul 13 '11 at 14:33

2 Answers2

3

In my case, it was using in C++ code a legacy C header containing #define NULL ((void *)0) in some legacy C header. My error message was "C2664 ...cannot convert argument 3 from void * to const_locale_t". The argument in question was NULL. Normally NULL is defined inside vcruntime.h (part of Visual C++). Using the custom NULL before any code that depends on vcruntime.h, like string.h, stdio.h, caused this error. Removing our custom definition or changing it to the following solved the problem.

#ifndef NULL
#ifdef __cplusplus
/*C++ NULL definition*/
#define NULL 0
#else
/*C NULL definition*/
#define NULL ((void *)0)
#endif
#endif
Samil
  • 958
  • 1
  • 17
  • 20
3

I've also seen this issue in a code I was dealing with. The problem was that stdlib.h was being included after a local header which probably was including some other c or c++ header.

wrong order:

#include "someheaderofmine.h"//includes several other headers
#include <stdlib.h>

just reversing the include order fixed my problem:

#include <stdlib.h>
#include "someheaderofmine.h"

seems like the same problem can occur if you are using string.h

Mert
  • 625
  • 1
  • 4
  • 23