Search code examples
linkersdllinker-errorsprogram-entry-pointargc

Importance of main() parameters


I'm starting out on SDL using CodeBlocks IDE. I got an error undefined reference to 'SDL_main'. I researched and found out that you need to have the parameters

int argc, char* args[]

in the main(). I added those and the code compiled and worked. My question is, how important are the parameters for the linker to be able to work?


Solution

  • Main parameters have to be there because SDL defines main internally as ......SDL_main(int argc, char *argv[])... depending on the system and does some initialization.

    Just include main parameters, it doesn't matter if you're not using them.