'SDL_main' : must return a value

I am fairly new to programming and am currently using a tutorial on how to perform ray casting. I downloaded a source file from the tutorial's web site, and some header files to go along with it. (If anyone is interested, the website is http://lodev.org/cgtutor/ ).

Every time I try to compile the .cpp file, I get a "raycaster_flat.cpp(228): error C4716: 'SDL_main' : must return a value" error. I can't figure out for the life of me what this means. Am I supposed to put a return in my .cpp or maybe in the SDL_main header?

Help would be appreciated.
Compiler is saying function SDL_main is declared to return a value but it is actually not.
This sound like the SDL thing where SDL renames your main to SDL_main .
Try this and see if it helps.

1
2
3
4
5
6
7
8
9
10
#include <SDL.h>
//maybe other includes

int main()
{

       //your code here.
    
     return 0;  //***put in a return statement**.
}
On some platforms SDL defines main as SDL_main so that SDL can create their own main function that run code before or after your main function (which really is SDL_main). At least I think that is the reason.
#define main SDL_main

This means that you have to write the return statement explicitly in main. I have never thought about this. I guess I will have to add a few return 0; in my own SDL projects.
Topic archived. No new replies allowed.