[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Register and static variables
From: |
Joerg Wunsch |
Subject: |
Re: [avr-gcc-list] Register and static variables |
Date: |
Mon, 25 Mar 2002 18:26:26 +0100 (MET) |
Geoffrey Wossum <address@hidden> wrote:
>> Is it possible to declare a global variable, but forcing it to be in
>> registers instead SRAM?
> You can declare it with the register specifier, i.e. "register int
> rint;", but this isn't a gurantee that it will be kept in a register
> the entire time.
IMHO the "register" keyword is normally only valid for variables of
storage class "auto".
However (somewhat to my surprise, but this feature might be valuable
for MCU programming), gcc extends the syntax, and allows specific
register requests for global variables (documented in the GNU info
files under "C language extensions"), like
register uint8_t foo asm("r14");
Of course, the programmer is then responsible to bind the variable to
a register that isn't used otherwise, but fortunately, gcc at least
warns about clobbering it.
--
J"org Wunsch Unix support engineer
address@hidden http://www.interface-systems.de/~j/
avr-gcc-list at http://avr1.org