title: Unable to retrieve an error message from glGetShaderInfoLog
body: <p>I am attempting to build a simple OpenGL 3.2 program which consists of a single fragment shader, but I do not seem to be able to actually compile the shader. I'm fairly sure that my shader syntax is correct, but even if it's not, I am unable to retrieve an error message using <code>glGetShaderInfoLog</code>.</p>
  
  <p>I have developed a short program that shows this in action:</p>
  
  <pre><code>GLuint shader = glCreateShader(GL_FRAGMENT_SHADER);
  
  const char *shaderData =
              "#version 120\n"
              "void main()\n"
              "{\n"
              "    gl_FragColor = gl_Color;\n"
              "}\n";
  glShaderSource(shader, 1, &amp;shaderData, NULL);
  
  GLint status;
  glGetShaderiv(shader, GL_COMPILE_STATUS, &amp;status);
  
  if (status == GL_FALSE)
  {
      GLint infoLogLength;
      glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &amp;infoLogLength);
  
      GLchar* strInfoLog = new GLchar[infoLogLength + 1];
      glGetShaderInfoLog(shader, infoLogLength, NULL, strInfoLog);
  
      fprintf(stderr, "Compilation error in shader %s: %s\n", this-&gt;name, strInfoLog);
      delete[] strInfoLog;
  }
  </code></pre>
  
  <p>This yields the message:</p>
  
  <blockquote>
    <p>Compilation error in shader Fragment Shader: </p>
  </blockquote>
  
  <p>The issue seems to be that the call to <code>getShaderiv</code> to retrieve the <code>GL_INFO_LOG_LENGTH</code> value returns 0 every time, so therefore I allocate an empty string. I have tried hard-coding this value to 100, but I still receive nothing from <code>getShaderInfoLog</code>. </p>
  
  <p>My concern here is not to fix the shader (I can do that myself if it is wrong), but to get the debug information. I know that this can be done, because I have used <a href="http://cg.in.tu-clausthal.de/teaching/shader_maker/index.shtml" rel="nofollow">Shader Maker</a> to develop shaders briefly, and I am able to get very detailed debug messages. For example:</p>
  
  <blockquote>
    <p><code>ERROR: 0:11: 'undefined_variable' : syntax error syntax error</code></p>
  </blockquote>
  
  <p>Unless Shader Marker has its own validation tool internally, I'm sure it has to be using the same method that I am trying to use. I have seen several examples on the internet in which people retrieve the error message for a shader in the same way, so I'm fairly sure I'm doing it correctly.</p>
  
  <p>Now, I am getting a compile-time warning which could potentially explain this problem:</p>
  
  <blockquote>
    <p><code>#warning gl.h and gl3.h are both included.  Compiler will not invoke errors if using removed OpenGL functionality.</code></p>
  </blockquote>
  
  <p>After doing a full text search, I cannot find anywhere where I call <code>#include &lt;OpenGL/gl.h&gt;</code>, so I am guessing that this header is being included by one of the <code>NSOpenGL*</code> classes. I'm fairly sure that I'm not using any removed functionality in this short program, and this issue only has about 5 hits on Google, but I thought I'd better mention this anyway.</p>