avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] memcpy() : problem when passing destination pointer


From: Vincent Trouilliez
Subject: Re: [avr-gcc-list] memcpy() : problem when passing destination pointer
Date: Wed, 11 Feb 2009 03:01:34 +0100

On Tue, 10 Feb 2009 21:56:39 +0100 (MET)
address@hidden (Joerg Wunsch) wrote:
> As the code works as is (with the warning), I bet the volatile
> qualification wasn't needed at all in the first place, and could as
> well be omitted.

I can't find any reference to the volatile keyboard in the
current avr-libc manual (1.6.2), but my understanding of volatile comes
from an older avr-libc manual (somewhere in the FAQ section IIRc) years
ago when I debuted my AVR project.
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.

In my case I was writing to a buffer from an ISR, but it was not read
in that C file, only from a different one, hence invisible to the
compiler. So my understading was: "in that particular file, GCC sees
that I am writing to the buffer, but never reading it, so he might
think it's useless to write to it ! So I added the volatile keyword,
thinking it would stop him from thinking too much ! ;-)

Is my understanding of volatile wrong ?

--
Vince




reply via email to

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