简体   繁体   中英

Compiler Error C2664 or C2731 C++ 2015

I have been able to fine the WinMain function. Now I'm trying to make a win32 app:

#include <Windows.h>
int WINAPI WinMain() {
    MessageBox(NULL,"Test", "Hello World", NULL);
    return 0;
}

and then I get error C2731 .

You haven't provided any parameters to the WinMain() method, and the error C2731 is saying that this method cannot be overloaded .

From MSDN :

int WINAPI WinMain(HINSTANCE hInstance,
               HINSTANCE hPrevInstance,
               LPSTR lpCmdLine,
               int nCmdShow);

Error C2664 is most likely your call to MessageBox, so try changing to something like:

MessageBox(NULL, L"Test", L"Hello World", NULL);

我发现我没有使用int main.cpp作为我的主要源代码文件,我的WinMain需要切换到wWinMain

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM