开发者

How to resolve error C2664 _vswprintf_c_l error in visual studio 2005?

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\i开发者_StackOverflownclude\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


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


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜