Hi!
I’m making a program on Visual Studio 2017 and I keep getting error code C2084
function 'int SDL_main(int,char *[])' already has a body
which as per Microsoft’s documentation says that the function has already been declared previously.
However, I have only declared the main function once on the entire program so I’m not sure what might be causing it. Any ideas what it might be?
The main.cpp I currently have is this and it’s the only file with a main function:
#define SDL_MAIN_HANDLED
#include <stdio.h>
#include <fstream>
#include <stdint.h>
#include <SDL.h>
#include <iostream>
#include <ostream>
#include <string>
#include <sstream>
#include <istream>
#include <SDL_image.h>
#include <scrnInfo.h>
#include <runtime.h>
#include <renderFunctions.h>
#include <SDL_ttf.h>
using namespace std;
int main(int, char**)
{
if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
{
logSDLError(cout, "SDL_Init");
return 1;
}
//Loading config file below
//scrnInfo info = scrnInfo();
//info.readConfig("config.ini");
SDL_Window *win = SDL_CreateWindow("Want some succ?", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_SHOWN);
if (win == nullptr)
{
logSDLError(cout, "SDL_CreateWindow");
SDL_Quit();
return 1;
}
Config info = Config(win);
info.readConfig("config.ini", win);
SDL_SetWindowPosition(win, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
SDL_Event event;
bool quit = false;
bool displaySplash = true;
bool ngplus = info.getNgPlus();
SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (ren == nullptr)
{
logSDLError(cout, "SDL_CreateRenderer");
SDL_Quit();
return 1;
}
/*SDL_Texture *splash = loadTexture("Resources/BG/splash_placeholder.png", ren);
if (splash == nullptr)
{
SDL_DestroyTexture(splash);
SDL_DestroyRenderer(ren);
SDL_DestroyWindow(win);
logSDLError(cout, "loadTexture");
return 1;
}
*/
while (!quit)
{
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case (SDL_QUIT):
{
quit = true;
return 0;
}
}
switch (event.key.keysym.sym)
{
case (SDLK_LALT | SDLK_F4):
{
quit = true;
return 0;
}
case (SDLK_LALT | SDLK_RETURN):
{
bool status = info.getFullscreenStatus();
if (!status)
{
SDL_SetWindowFullscreen(win, SDL_WINDOW_FULLSCREEN_DESKTOP);
}
else
{
SDL_SetWindowFullscreen(win, 0);
}
}
}
}
if (displaySplash == true)
{
FadingSplashScreen(2000, ren, info , 255, 255, 255, 255);
displaySplash = false;
}
menuLoop(ngplus, win, ren, quit, &info);
}
}
Thanks for your attention!