简体   繁体   中英

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

I am trying to open a window using some SDL2 coding. However, every time I try to compile and run the code, visual studio always gives me the same error(s).

Error: 'identifier' : function cannot be overloaded

Here is my code:

#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;


}

Here is some warnings they gave me in case they matter:

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

Warning #2: 'APIENTRY': macro redefinition

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

Use int main(int argc, char* argv[]) instead. More details here .

Warning #2: 'APIENTRY': macro redefinition

Remove #include <Windows.h> , you don't seem to need it.

(If you do need it, try placing it above other includes. Alternatively, try adding #undef APIENTRY before #include <Windows.h> . )

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