[英]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.