
Why SDL defines main macro? - Stack Overflow
2015年10月10日 · After having some trouble setting up SDL, I found out that SDL defines a macro that replaces main: #define main SDL_main // And then extern C_LINKAGE int SDL_main(int argc, char *argv[]); This can also create compilation errors, if the main function doesn't have the argc and argv parameters defined. This macro gives me headaches just when I …
c++ - Undefined reference to 'SDL_main' - Stack Overflow
2015年1月2日 · As pointed out by HolyBlackCat, this is a pretty sloppy fix. SDL replaces the main function in order to perform some initialization and/or cleanup that is otherwise not possible, and then calls back to the actual user function. The interception works by replacing the name of user's main function to SDL_main, with a simple macro. #define main ...
Do I need SDL's main () function? - Stack Overflow
2016年11月16日 · Instead of #undef main you should #define SDL_MAIN_HANDLED before including SDL.h (or define it via compiler flag). If you implement custom main function you should at least call SDL_SetMainReady . For some platforms, SDL performs additional operations, like setting specific exception handlers, converting arguments to UTF8, or something ...
c++ - 'SDL_main' : must return a value - Stack Overflow
2013年3月29日 · It's because SDL defines a macro like this: #define main SDL_main So the function you've written is actually called SDL_main and like any other function that is not the actual main function, if it doesn't return void, you have to give it a return statement.
undefined reference to WinMain@16 C++, SDL-2 - Stack Overflow
2015年9月2日 · What happens is, main is defined as a macro in the SDL header and this causes your main to be renamed to SDL_main or similar. Then, in the "SDL_main" library a different main is defined which will be the real main of your application. This main just fetches the command-line arguments in whatever way is appropriate for the platform, and calls ...
Undefined reference to 'SDL_main' while using Dev C++
2015年10月12日 · In the background, SDL defines a macro #define main SDL_main that renames your main(int argc, char *argv[]) function so that it does not conflict with its own main() function (used for SDL initialization). If you use main() instead, the macro does not modify it and SDL_main is then not found. If it does not work, follow these steps:
'unresolved external symbol _SDL_main referenced in function' …
2013年9月15日 · Ive tried #undef main (Which comes up with another error) & and even redefining it to no avail. Ive also tried several other attempts such as creating it as a Windows Console project. Ive also tried several other attempts such as creating it …
windows - undefined reference to `SDL_main' - Stack Overflow
2013年7月24日 · I understand that main has to have the int main(int argc, char *argv[]) signature, and #include <SDL.h> in that file, but it still does not work. windows eclipse
Linker Error when using the SDL Library: _main already defined in …
2016年8月6日 · Try also this at the top of your main.cpp file: #define SDL_MAIN_HANDLED That is supposed to cause SDL to skip all of its main nonsense. Note that it needs to happen before you include SDL: #define SDL_MAIN_HANDLED #include "SDL2/SDL.h"
multiple definition of `main' when including SDL.h
2018年2月17日 · So in your code instead of main() you should define function. int SDL_main(int argc, char *argv[]) Note that if SDL_MAIN_NEEDED or SDL_MAIN_AVAILABLE is defined then SDL will redefine main as SDL_main automatically so there is …