George George - 2 months ago 14
C++ Question

Why is there no semicolon at the end of this call to `initShaders()` (OpenGL/C++)

Consider the following snippet of code from an OpenGL tutorial:

int main()
{
initGlutState();
glewInit();
initGLState();
initShaders() //why is there no semicolon on this line?
initVBOs();
glutMainLoop();
return 0;
}


Why is there no semicolon on the call to
initShaders()
? Does that mean this is a macro call?

Answer

It's a typo. In C++ using clang++ this would not compile and throw the following error.

error: expected ';' after expression

There is a small possibility that it is a macro, but I doubt it, and that would be a very unconventional, i.e., bad way of writing one.

Comments