[En-Nut-Discussion] Hardware Register Access Using Volatile Pointer
Bernd Walter
enut at cicely.de
Tue Apr 26 18:32:30 CEST 2011
On Tue, Apr 26, 2011 at 02:26:16PM +0200, Harald Kipp wrote:
> On 4/26/2011 12:59 PM, Bernd Walter wrote:
> > On Tue, Apr 26, 2011 at 09:33:26AM +0200, Harald Kipp wrote:
> >> int dummy;
> >> ...
> >> dummy = inr(TC0_SR);
> >
> > (void) dummy;
>
> What? Is this some secret in the language I'm not aware of, or just a
> typo, meaning
>
> (void) inr(TC0_SR);
>
> Still I can't follow. GCC 4.6 doesn't like unused local variables, it
> doesn't require to to cast the function result.
It cast's away the warning in that you declare the dummy variable
to be intentionally unused.
You can use the variable anyway, but it shuts up the compiler if you
are not using it.
I use it quite often - especially for function arguments, which
are there to satisfy an interface definition but which are useless
for the concrete implementation.
For example if you have a thread which doesn't need arg:
static
THREAD(PidThread, arg)
{
(void)arg;
...
}
--
B.Walter <bernd at bwct.de> http://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.
More information about the En-Nut-Discussion
mailing list