if (fcinfo->context && IsA(fcinfo->context, AggState))
aggcontext = ((AggState *) fcinfo->context)->aggcontext;
-#if POSTGIS_PGSQL_VERSION >= 84
+#if POSTGIS_PGSQL_VERSION == 84
else if (fcinfo->context && IsA(fcinfo->context, WindowAggState))
aggcontext = ((WindowAggState *) fcinfo->context)->wincontext;
+#endif
+#if POSTGIS_PGSQL_VERSION > 84
+ else if (fcinfo->context && IsA(fcinfo->context, WindowAggState))
+ aggcontext = ((WindowAggState *) fcinfo->context)->aggcontext;
#endif
else
{