簡體   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