'main' cannot be overloaded

I’m trying to compile a sample code from an OpenGl book and it’s giving me that main is being overloaded. I’m not really educated about overloading nor OpenGL; can someone explain why it’s overloaded and how to fix the compiler issue? I feel like this is probably due to my lack of knowledge in overloading but this is from the book, so I would assume it is correct.

#include <GL/glut.h>
#include <GL/GL.h>

void RenderScene(void)

void SetupRC(void)
	glClearColor(0.0f, 0.0f, 1.0f, 1.0f);

void main(void);
	int main(int argc, char* argv[])
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
	return 0;

  • Sean

Sorry, I was a bit unclear on the error.

Chap2.cpp(17): error C2731: ‘main’ : function cannot be overloaded

A function is overloaded when there are multiple functions sharing the same name but different arguments. The compiler decides which function to actually invoke based on the arguments you pass to it.

Right before line 17, you have:

void main(void);

On the next line, you have:

int main(int argc, char* argv[])

The main function is the entry point for C(++) programs. There can only be one of these per program, because there can only be one point to start executing.

The C standard states that main should return an int. If you want to access command-line arguments, then you use the arguments you have to the second main.