繁体   English   中英

SDL2代码的函数重载问题? 必须定义错误入口点?

[英]Function overloading problem with SDL2 code? Error Entry Point must be defined?

我正在尝试使用一些SDL2编码打开一个窗口。 但是,每次我尝试编译和运行代码时,Visual Studio总是给我相同的错误。

Error: 'identifier' : function cannot be overloaded

这是我的代码:

#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <SDL.h>
#include <SDL_opengl.h>
#include <SDL_image.h>
#include <Windows.h>
using namespace std;

const int WIDTH = 800, HEIGHT = 600;

int WinMain(int argc, char* argv[])
{
    SDL_Init(SDL_INIT_EVERYTHING);

    SDL_Window *window = SDL_CreateWindow("Hello SDL World", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_ALLOW_HIGHDPI);

    // Check that the window was successfully created
    if (NULL == window)
    {
        // In the case that the window could not be made...
        std::cout << "Could not create window: " << SDL_GetError() << std::endl;
        return 1;
    }

    SDL_Event windowEvent;

    while (true)
    {
        if (SDL_PollEvent(&windowEvent))
        {
            if (SDL_QUIT == windowEvent.type)
            {
                break;
            }
        }
    }

    SDL_DestroyWindow(window);
    SDL_Quit();

    return EXIT_SUCCESS;


}

以下是他们给我的一些警告:

Warning #1: 'WinMain': Must be '_stdcall'

Warning #2: 'APIENTRY': macro redefinition

警告#1:“ WinMain”:必须为“ _stdcall”

请改用int main(int argc, char* argv[]) 更多细节在这里

警告2:“ APIENTRY”:宏重新定义

删除#include <Windows.h> ,您似乎不需要它。

(如果确实需要,请尝试将其放置在其他include之上。或者,尝试在#include <Windows.h>之前添加#undef APIENTRY 。)

暂无
暂无

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

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