GLSL Stringify macro fails in some cases


#1

I was just struggling with this for a while, thought I’d post it in case someone else has found this issue. When using the STRINGIFY macro:

#define STRINGIFY(A) #A

For vertex or fragment shaders, I sometimes got a weird error saying:

glsl unexpected $end, expecting ‘,’ or ‘;’ at token < EOF >

I don’t know why, but it was some float declarations in the style of:

float a, b, c;

It should be:

float a;
float b;
float c;

This is quite useful because at least with VS2012, I get syntax highlighting for GLSL when using STRINGIFY.

Hope it helps someone!


Shader setupShaderFromSource not working
#2

yes, comas will be parsed as separators for parameters of the macro and stringify will fail. also using # inside stringify won’t work