简体   繁体   English

类型“ const char *”的参数与类型“ LPCWSTR”的参数不兼容

[英]argument of type “const char *” is incompatible with parameter of type “LPCWSTR”

I have a very big problem... I' ve started today morning programming in Windows.h but I can't figure out why it gave me this problem as I litteraly copy the thing in the tut. 我有一个很大的问题...我今天早上开始在Windows.h中编程,但是当我乱扔东西复制到tut中时,我不知道为什么它给了我这个问题。 ( https://youtu.be/8GCvZs55mEM?t=5m20s ) (I put the link to start the video when occurs my error) https://youtu.be/8GCvZs55mEM?t=5m20s )(发生错误时,我将链接放到开始播放视频的位置)

The only thing I noticed is that in the tut it uses a LPCSTR variable for test, but my editor (Visual Studio Code) signal a LPCWSTR variable. 我唯一注意到的是,在tut中它使用LPCSTR变量进行测试,但是我的编辑器(Visual Studio Code)发出LPCWSTR变量的信号。

Sorry for the bad English. 对不起,英语不好。

#include <windows.h>

using namespace std;

int WINAPI WinMain (HINSTANCE hInts, HINSTANCE hPrevInst, LPSTR args, int ncmdshow)
{

MessageBox(NULL, "Ciao!", "La prima GUI", MB_OK, );

return 0;
}

How can I solve? 我该如何解决?

In the comment: 在评论中:

Now the error don't show up, thanks a lot. 现在不显示错误,非常感谢。 But there is a problem... The editor don' t built the application. 但是有一个问题...编辑器没有构建应用程序。 The Console give: 控制台提供:

Executing task: g++ -g main.cpp -o Program <  
main.cpp: In function 'int WinMain(void *, void *, char *, int)':
main.coo:8: pasing '__wchar_t *' as argument 2 of 'MessageBox(void *, const char *, const char *, UINT)'

Obviously not a good tutorial. 显然不是一个很好的教程。 Do it like like this 像这样做

MessageBox(NULL, L"Ciao!", L"La prima GUI", MB_OK);

Using L changes the string literal so that it uses wide characters. 使用L更改字符串文字,以便使用宽字符。 A wide character string literal can be converted to the type LPCWSTR , a normal string literal cannot. 宽字符串文字可以转换为LPCWSTR类型,而普通字符串文字则不能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 2 IntelliSense:类型为“ const char *”的参数与类型为“ LPCWSTR”的参数不兼容 - 2 IntelliSense: argument of type “const char *” is incompatible with parameter of type “LPCWSTR” IntelliSense:“ const char *”类型的参数与“ LPCWSTR”类型的参数不兼容 - IntelliSense: argument of type “const char *” is incompatible with parameter of type “LPCWSTR” “const char *”类型的参数与“LPCWSTR”类型的参数不兼容 Visual Studio 2019 - Argument of type “const char *” is incompatible with parameter of type “LPCWSTR” Visual Studio 2019 错误:char* 类型的参数与 LPCWSTR 类型的参数不兼容 - Error: argument of type char* is incompatible with parameter of type LPCWSTR “ char *”类型的参数与“ STRSAFE_LPCWSTR”类型的参数不兼容 - argument of type “char *” is incompatible with parameter of type "STRSAFE_LPCWSTR “ const char **”类型的参数与“ const char *”类型的参数不兼容 - Argument of type “const char **” is incompatible with parameter of type “const char *” WORD *类型的参数与LPCWSTR类型的参数不兼容 - argument of type WORD* is incompatible with parameter of type LPCWSTR “LPCWSTR”类型的参数与“LPCSTR”类型的参数不兼容 - Argument of type “LPCWSTR” is incompatible of the parameter of type “LPCSTR” “unsigned char *”类型的参数与“const char *”类型的参数不兼容 - Argument of type "unsigned char *" is incompatible with parameter of type "const char *" 类型“ const char *”的参数与类型“ char *”的参数不兼容。 但为什么? :( - Argument of type “const char*” is incompatible with parameter of type “char*”. But why? :(
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM