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
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It only takes a minute to sign up.
Sign up to join this communityWhy 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?
Nov 20, 2018 at 18:02