What's wrong?

i absolutely cannot figure out what i did wrong with this. i copied this straight out of a book. obviously its opengl, but the problem is not with that, i dont think. when i try to compile (in dev-c++) it merely says "line:22 `main' must return `int'" what did i do? i entered a "return 1;"!

#include
#include

// called to draw scene
void RenderScene(void)
{
// clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT);

// flush drawing commands
glFlush();
}

// setup the rendering state
void SetupRC(void)
{
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
}

// main program entry point
void main(void)
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow("Simple");
glutDisplayFunc(RenderScene);

SetupRC();

glutMainLoop();
return 1;
}

Comments

  • You are specifying that your main() routine returns 1, but you defined it to return nothing.

    Also, "return 0;" indicates success on most systems. Your current program will return a system error code 1.

    Change main() to this:

    [code]// main program entry point
    int main(void)
    {
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutCreateWindow("Simple");
    glutDisplayFunc(RenderScene);

    SetupRC();

    glutMainLoop();
    return 0;
    }[/code]

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.brokenthorn.com]Website :: OS Development Series[rightbr][/link][/size]
  • A perfect example of how many authors of books there are who are clueless about the C/C++ standard. To write a program, you need to know the C standard. To write a book, you only need to know how to write. ;-)
  • : A perfect example of how many authors of books there are who are
    : clueless about the C/C++ standard. To write a program, you need to
    : know the C standard. To write a book, you only need to know how to
    : write. ;-)

    Very true, Lundin
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories