显示错误:
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
它找到文件 - C:\Program Files\Microsoft Visual Studio 8\VC\include\swprintf.inl
,这是我猜的系统文件。那么,如何解决?
平台:Visual Studio 2005 版本8.0.50727.762
答案 0 :(得分:3)
我也在我正在处理的代码中看到了这个问题。 问题是stdlib.h被包含在一个本地标题之后,可能包含了一些其他的c或c ++标题。
错误的订单:
#include "someheaderofmine.h"//includes several other headers
#include <stdlib.h>
只是颠倒包含顺序修复了我的问题:
#include <stdlib.h>
#include "someheaderofmine.h"
如果您使用string.h,似乎会出现同样的问题
答案 1 :(得分:0)
在我的情况下,它使用的是C ++代码中的旧C标头,其中某些旧C标头中包含 #define NULL((void *)0)。我的错误消息是“ C2664 ...无法将参数3从void *转换为const_locale_t”。有争议的参数为NULL。通常在 vcruntime.h (Visual C ++的一部分)中定义NULL。在依赖vcruntime.h的任何代码(例如string.h,stdio.h)之前使用自定义NULL会导致此错误。删除我们的自定义定义或将其更改为以下内容即可解决问题。
#ifndef NULL
#ifdef __cplusplus
/*C++ NULL definition*/
#define NULL 0
#else
/*C NULL definition*/
#define NULL ((void *)0)
#endif
#endif