Q:

Segfault with glPrimitiveRestartIndex

I'm having trouble with glPrimitiveRestartIndex
My code compiles and links, but when I run it, it segfaults on the line:
glPrimitiveRestartIndex(0xffff);

glEnable(GL_PRIMITIVE_RESTART) gives me invalid enumerant when i poll with glGetError and glGetErrorString
I found a similar question, and it suggested that glew might not be initialized properly.
I'm initializing glew before I do this, and I'm also including the glew.h before gl.h.
Also, glewinfo | grep Restart gives me
glPrimitiveRestartIndex:                                     OK
glPrimitiveRestartIndexNV:                                   OK
glPrimitiveRestartNV:                                        OK

So shouldn't it work on my system? What could be wrong?
My code is fairly big, so I can't post everything, here is what I think is relevant:
if (GLEW_OK != glewInit()){
    // GLEW failed!
    std::cout << "Failed to initialize glew!\n";
    exit(1);
}
glEnable(GL_PRIMITIVE_RESTART); //invalid enumerator
glPrimitiveRestartIndex(0xffff); //segfault!

A:

glPrimitiveRestartIndex

Is OpenGL 3.1 +
You should check to see if your driver supports it, by checking it like so:
if(GLEW_VERSION_3_1) {
  //we are running on 3.1 +
} else {
  //some version lower than 3.1
}

