ESP8266 MQTT client error
In C++, you can't use or reference a function before it is declared, that's not Arduino specific, it's how C++ "works"

Moving the callback function above the client declaration won't help, because the callback function references client

The only solution is to declare the callback function before it is referenced in client initialisation, but have the definition of callback after

i.e. add one line

WiFiClient wifiClient;
void callback(char* topic, byte* payload, unsigned int length); // add this in your code
PubSubClient client(MQTT_SERVER, 1883, callback, wifiClient);


Nothing else needs to be changed

Please excuse some terminology mistakes above - it's been a long time since I learned C/C++, while I know how to use it, I don't always know how to describe it :p


  apprently there's some bug in the toolchain - see the comments in the question. However, this is still a valid solution, I guess it works around the bug