# I can't seem to figure out what's causing this bug with the “layout” keyword in GLSL

I have a GL shader file whose first few lines currently look like this:

#version 120
layout (location = 0) in vec3 position;
layout (location = 1) in vec2 vertexUV;


When I try to compile this shader when running the program, it returns this error:

0:2(1): error: syntax error, unexpected NEW_IDENTIFIER


From what I know, this means that the word layout is giving it trouble. What am I doing wrong? Do I need to provide more information?

I believe that the problem is that you are trying to use the layout keyword, but the version is set at 120. Try changing the first line to #version 330. There is an alternative way of setting attribute locations, which can be found in this answer.
• Also, my version of Mesa is GL 3.0, I can't use any versions higher than 130. – Joe Z. Jan 14 '14 at 6:23
• @JoeZ.: every driver vendor (NVIDIA, AMD, Intel, Mesa, etc.) has to reimplement the GLSL compiler from scratch. There are lots of bugs and conformance violations all over the place. Just because one vendor accepts newer GLSL code with an old #version directive doesn't mean it's correct. Also be aware that just because the driver only supports GL 3.0 doesn't mean it won't support a newer version of GLSL as an extension; the latest Mesa should support up to GLSL 3.30 with some drivers (not sure which ones). – Sean Middleditch Jan 14 '14 at 7:54
• So I figured out that enabling GL_ARB_explicit_attrib_location made that error go away. – Joe Z. Jan 14 '14 at 18:31
• @JoeZ. I added an alternative method for setting attribute locations to the answer. I know you already solved it using GL_ARB_explicit_attrib_location, but that should help other people if that doesn't work for them. – Lysol Jan 15 '14 at 3:17