Syntax error using gl_FragDepth

Hi folks,

I am getting the following error when doing a glCompileShader() on my frag shader code:

error C0000: syntax error, unexpected $undefined, expecting “::” at token “<undefined>”

The line of code that is complaining about is:

gl_FragDepth​ = 1.0f;

I have never seen this error ever. Any idea what might cause that?

For the record, I tried explicitly setting my shader version to
#version 120
and also a newer version
#version 150
Same error. Any help decoding this error would be greatly appreciated.

The line of code that is complaining about is

First rule of compiler errors: just because it lists that line does not mean that it’s the cause of the error. That’s just where the compiler realized that something was wrong. If a line of code looks innocuous, that means the error probably happened somewhere before then.

Even more confusing is that :: is not a token of GLSL. It should never be something the compiler expects. So I’m going to go out on a limb and suggest that you’re probably passing the shader text to OpenGL incorrectly.

Oh, and #version declarations should not be considered optional.

[QUOTE=Alfonse Reinheart;1280096]First rule of compiler errors: just because it lists that line does not mean that it’s the cause of the error. That’s just where the compiler realized that something was wrong. If a line of code looks innocuous, that means the error probably happened somewhere before then.

Even more confusing is that :: is not a token of GLSL. It should never be something the compiler expects. So I’m going to go out on a limb and suggest that you’re probably passing the shader text to OpenGL incorrectly.[/QUOTE]

And, it turns out that the problem was that MSVC was putting some garbage chars in the raw text, and hiding it from my view. I looked at the file in another editor and saw this:

gl_FragDepth​ = 1.0f;

Works fine when I clean that up.

Good to know. Thanks!

FYI if you’re curious about where that character came from.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.