error C2664

VS编译常见错误

Posted by 雯饰太一 on May 22, 2023

error C2664

error C2664: 不能将参数 1 从“const char [14]”转换为“LPCWSTR”

原因:没有设置多字符集

解决方案:

  • 【属性】->【常规】->【字符集】(选择多字符集)

  • 如果还是编译不能通过,【属性】à【C/C++】à【预处理器】(如果有UNICODE,去掉即可)

prsht.h(643): error [该文件中出现的相关错误]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\prsht.h(643): error C2146: 语法错误: 缺少“;(在标识符“hdr”的前面)
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\prsht.h(643): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\prsht.h(643): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int

//对应代码中的位置如下:
typedef struct _PSHNOTIFY
{
    NMHDR hdr;
    LPARAM lParam;
} PSHNOTIFY, *LPPSHNOTIFY;

if (dRetCode != 0) 
{
	AttachConsole(GetCurrentProcessId());
}

解决方法:

在某个主要的.h文件中,[#include ]

备注:上述错误是因为找不到声明,只需要将其引入即可

但是具体怎么定位是在哪个文件中添加就不知道了,当时也只是歪打正着。