Why in the piece of code below we use "static volatile bool"?
static volatile bool wifi_connected = false;
taken from here: https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/WiFiIPv6/WiFiIPv6.ino
Why in the piece of code below we use "static volatile bool"?
static volatile bool wifi_connected = false;
taken from here: https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/WiFiIPv6/WiFiIPv6.ino
static
means that the global will only be accessible inside the current translation unit.
volatile
means that while(!wifi_connected){/*...*/}
cannot be optimized to if(!wifi_connected)while(true){/*...*/}
These things are orthogonal. So you would use static volatile when you need both properties.
wifi_connected
were changed? If not - how would it handle exiting the loop in the (eventual) case that the variable changes?
– Brydon Gibson
Nov 20 '18 at 18:02