Sign in to follow this  
L. Spiro

Warning is an Unwanted Nuisance

Recommended Posts

WARNING: 4:1: warning(#239) Declaration should include a precision qualifier or the default precision should have been previously declared

Great. Now that I have manually specified a precision qualifier for every single variable in the shader, please stop warning me of this.

#version 140
// Uniforms.
//uniform mat4 g_mModelViewProj;
uniform mediump mat4 g_mProj;
uniform mediump mat4 g_mModelView;


Etc.
Every variable (including function locals) has mediump in its declaration, yet relentlessly this warning appears.

Any idea how to make this annoying warning get lost?


And what is 4:1: supposed to mean anyway?
Logically I would assume line:character:, but I know that these numbers are 0-based, which means line 4 is actually line 5, which is uniform mediump mat4 g_mModelView;, which not only includes a precision qualifier, but is the [i]second[i] declaration in the file.
I mean if it was line:character:, it would have warned me on uniform mediump mat4 g_mProj;, which is, from 0, line 3, not 4.
I only get one of these warnings per file (and in every file), so if it is going to whine about g_mModelView, it would have whined about g_mProj first, so if it is line:character: it should be 3:0:, not 4:1:.


Yogurt Emperor

Share this post


Link to post
Share on other sites
I thought it should be the line number also, but as I said I know it is 0-based because I have seen others who have this warning but with 0’s.

Additionally, I can freely add some blank lines, remove commented-out lines, etc., to move the lines of my declarations, but it always prints 4:1:, regardless of the actual line number of any of my declarations.

My fragment shader gives me:
WARNING: 0:5: warning(#239) Declaration should include a precision qualifier or the default precision should have been previously declared

Line 0?? #version 140?? This 4:1: and 0:5: junk is useless!


And mediump is a so-far literally useless keyword that is not implemented.
Not even documented in my OpenGL Shading Language Third Edition book. It is somehow related to OpenGL ES, but still not implemented.


Making this warning all-in-all entirely senseless, useless, and annoying.


Why do I care so much?
#1: I do not write code that generates warnings. Period. In fact it was MY idea at the office that anyone who submits warning-generating code on Friday has to pay 500円 per warning.
#2: If you search for this exact string of text, you will find a variation of it:
ERROR: 0:2: '' : Declaration must include a precision qualifier or the default precision must have been previously declared.

Which means at some point, either when I move to a newer version or to a lower version (as I will in order to maximize compatibility) I will get an error instead of a warning, and I will have to solve this.



Now here is the kicker.
I had already searched for this warning string before posting here but never saw anyone asking how to actually fix it. They just reported it along with a mess of other warnings/errors.
But just now when I went to get the ERROR version of this warning I found this:
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=253424

You have to take a close look but someone finally posted a solution there.
precision mediump float;

And it nearly makes me just as unhappy.

OpenGL Shading Language Third Edition uses version 140 throughout and is meant to be an up-to-date reference for 140.
Yet “precision” isn’t in the index, and there are no example shaders using this keyword.
If lacking this line of code is guaranteed to cause a warning on every single shader in the book, it might be a good idea to address this issue in the book!
In fact “mediump” isn’t in the book either.

And doing my own research found me this:
http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.40.05.pdf

The spec does mention it, but you would already have to know what it is to know that it is relevant to this warning, especially after I already tried putting mediump in front of every variable with no luck.

I still do not know what 4:1: and 0:5: were supposed to mean.


Yogurt Emperor

Share this post


Link to post
Share on other sites
Well when you have a clean compile, add in a line that will cause an error like:

vec3 a(1,1,1,1);//too many intializers

and see what happens when you move it around. Mine always prints the line from top starting at 1 I think.

Share this post


Link to post
Share on other sites
The specification should always be your first (or near first) reference.

GLSL version 1.50 and onwards include a default precision for floats (highp), so you might consider switching up a version if it's that much of an irritation.

I *think* that the 4:1 is actually the number of the shader source file / string compiled in the shader (i.e. if you send multiple source strings to glShaderSource), and then the line in that file.

Share this post


Link to post
Share on other sites
I got a similar error. The strange thing was that i got it only on some graphic cards.

I fixed it with the following line,

precision mediump float;

and the beginning of each shader.

I read somewhere that this qualifiers should only be needed with OpenGL ES but somehow it was needed.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this