Vincent Trouilliez <vincent.trouill...@modulonet.fr> wrote: > I can't find any reference to the volatile keyboard in the > current avr-libc manual (1.6.2), [...]
Note that volatile is explained in the C standard. > IIRC it said volatile must be used to keep the compiler from > optimizing away access to a variable that he thinks might be > pointless. Like writing a variable that is never read back. Nope, if the variable is a global one, it will always be written. Even in the canonical example, it's not that the compiler would /never/ read the flag variable. The only thing that happens without the volatile is that it reads the flag once (because it optimizes the expensive memory access outside the loop), so it will eventually miss the update to the variable that happens inside the ISR -- but it doesn't "throw away" the variable access completely. So in order to just pass some random value in an array between an ISR and another thread, it doesn't need to be volatile, as long as the receiver is not "spin looping" on a value out of that array. -- cheers, J"org .-.-. --... ...-- -.. . DL8DTL http://www.sax.de/~joerg/ NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-) _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list