Shader syntax error

I left the OpenGL world about twenty years ago and now with plenty of timeon my hands, I’m back. Following the excellent guidance of “Learn OpenGL” at LearnOpenGL - Shaders, I’m stuck at the very first example of linking vertex shaders to fragment shaders. The error is ERROR: 0:4: '{' : syntax error: syntax error. the offending code is

 // Vertex shader
    const char* vertexShaderSource = "#version 330 core\n"
        "layout (location = 0) in vec3 aPos;\n"
        "out vec4 vertexColor;\n"
        "void main()\n"
        "{\n"
        "   gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n"
        "   vertexColor = vec4(0.5, 0.0, 0.0, 1.0);\n"
        "}\0";
    unsigned int vertexShader;
    vertexShader = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
    glCompileShader(vertexShader);
    int  success;
    glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success);
    // declare infoLog here since it's used in two blocks below
    char infoLog[512];
    if(!success)
    {
        glGetShaderInfoLog(vertexShader, 512, NULL, infoLog);
        fputs(infoLog, stderr);
    }

    // Fragment shader
    const char* fragmentShaderSource = "#version 330 core\n"
        "out vec4 FragColor;\n"
        "in vec4 vertexColor;\n"
        "void main()\n"
        "{\n"
        "   FragColor = vertexColor;\n"
        "}\0";
    unsigned int fragmentShader;
    fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
    glCompileShader(fragmentShader);
    glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success);
    if(!success)

I’m pretty sure the issue will be obvious to someone more experienced than I in OpenGL, but I’ve looked at it until I’m bleary-eyed and can’t fathom what’s wrong. Any help will be appreciated

Okay, the answer seems to be in the version number. My system reports itself as version 4.1, so I changed from “330” to “410” and it seems to run just fine. But now I’m a little worried about a mismatch between the version used in the shader code (4.1) and the version used in the tutorial (3.3). Wish me luck,

You’ll probably be OK. IIRC, in GL 3.3+ (GLSL 330+) features have generally been added, not replaced.

GL 3.0 (GLSL 130) was the big removal of much old GLSL syntax. So just stay newer than that.

If you run into any issues, try using compatibility in your #version directive instead of core. That makes the GLSL compiler permissive of “the older stuff”.