[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Best practice for external variable (newbie-ish quest

From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Best practice for external variable (newbie-ish question)
Date: Sun, 20 Nov 2005 08:16:59 +0100 (MET)

Matthew Smith <address@hidden> wrote:

> volatile uint8_t foo;

>       extern uint8_t foo;

Note that they don't match.  The extern declaration is missing the
"volatile" keyword.  Keep in mind that volatile is nothing like a
memory allocation attribute or such that, once stuck onto a variable,
would be accessible to anyone using that variable.  Instead, it is a
so-called type qualifier, something that's purely intented for the
compiler to adjust its compilation strategy.  Thus, it must be
guaranteed that each part of the compilation knows about that

As Russell already mentioned, the best way to maintain that is by
placing a single declaration of the variable into a central header
file that is included from all source files.

cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]