Several shader warnings with Unity's SSAO image effect

I have a problem with Unity’s SSAO shader. I get the following warnings:

Shader warning in ‘Hidden/SSAO’: GLSL vertex shader: 335: ERROR: ‘]’ : syntax error parse error at line 60

Shader warning in ‘Hidden/SSAO’: GLSL vertex shader: 335: ERROR: ‘]’ : syntax error parse error at line 89

Shader warning in ‘Hidden/SSAO’: GLSL vertex shader: 335: ERROR: ‘]’ : syntax error parse error at line 124

Shader warning in ‘Hidden/SSAO’: GLSL vertex shader: 335: ERROR: ‘]’ : syntax error parse error at line 170

Shader warning in ‘Hidden/SSAO’: GLSL vertex shader: 335: ERROR: ‘]’ : syntax error parse error at line 243

These warnings appear whenever I have a camera with the SSAO image effect attached and create/edit another shader. What could be the problem, and how to solve it?

Not sure if this is the best solution but it works well for me. If you look towards the top of SSAOShader.shader, you will see:

#ifdef UNITY_COMPILER_HLSL

#	define INPUT_SAMPLE_COUNT 8
#	include "frag_ao.cginc"

#	define INPUT_SAMPLE_COUNT 14
#	include "frag_ao.cginc"

#	define INPUT_SAMPLE_COUNT 26
#	include "frag_ao.cginc"

#	define INPUT_SAMPLE_COUNT 34
#	include "frag_ao.cginc"

#else
#	define INPUT_SAMPLE_COUNT
#	include "frag_ao.cginc"
#endif

That’s the offending code. It’s shared with all the passes below. For HLSL it defines the function frag_ao multiple times with different sample counts. For GLSL it just leaves the sample count blank. GLSL seems to not like this. My fix was to break this up and move it into the passes that needed it. So for example my first pass looks like this:

	// ---- SSAO pass, 8 samples
	Pass {
		
CGPROGRAM
#pragma vertex vert_ao
#pragma fragment frag
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest

#define INPUT_SAMPLE_COUNT 8
#include "frag_ao.cginc"

half4 frag (v2f_ao i) : COLOR
{
	#define SAMPLE_COUNT 8
	const float3 RAND_SAMPLES[SAMPLE_COUNT] = {
		float3(0.01305719,0.5872321,-0.119337),
		float3(0.3230782,0.02207272,-0.4188725),
		float3(-0.310725,-0.191367,0.05613686),
		float3(-0.4796457,0.09398766,-0.5802653),
		float3(0.1399992,-0.3357702,0.5596789),
		float3(-0.2484578,0.2555322,0.3489439),
		float3(0.1871898,-0.702764,-0.2317479),
		float3(0.8849149,0.2842076,0.368524),
	};
    return frag_ao (i, SAMPLE_COUNT, RAND_SAMPLES);
}
ENDCG

	}

No more complaints! Hope this helps!