Declaring shared variables as volatile

Hi,
Should I use the volatile keyword when declaring global variables (and objects) that are accessed by both the main function and the audio callback function? Because the audio callback is called from an interrupt, right?
I am asking this because I don’t see any variables and/or objects declared as volatile in the example files.

Hey Jason!

It’s not usually necessary to use volatile, but you’re totally free to use it if you want as it should not cause any issue. Maybe slightly worse performance??

1 Like