Unfamiliar code construct

Copiedt following straight out of a Freescale application note. The second doesn't look familuar. Is this a standard C construct, and likely to be accepted by most IDEs? Does it just mean read SCISR1 and discard the result?

if (SCISR1 & 0x80){ SCISR1; if(*(SCIStringp++) != '\0'){ if(*SCIStringp > 0xD){ /*Avoid to change CR and LF characters*/ SCIDRL=*SCIStringp + Stringcase; } else{ SCIDRL=*SCIStringp;

Reply to
Bruce Varley
Loading thread data ...

Op Tue, 21 Jan 2014 13:34:40 +0100 schreef Bruce Varley :

If I read the C standard (n1570) right, then the expression is an lvalue of type void (implicitly) and shall be evaluated for its side effects. Accessing a volatile object is a side effect.

(Remove the obvious prefix to reply privately.) 
Gemaakt met Opera's e-mailprogramma: http://www.opera.com/mail/
Reply to
Boudewijn Dijkstra

Bruce Varley schreef op 21-Jan-14 1:34 PM:

My guess is that SCISR1 is a macro for some register, something like

#define SCISR1 (*((volatile unsigned int *) 0x327F ))

that line with only SCISR1; would read the register a second time (the condition read it a first time). Maybe this is needed to clear the register or achieve some other side-effect. Check the documentation :)

Wouter van Ooijen

Reply to
Wouter van Ooijen

I prefer to write

(void) SCISR1;

in cases like this, to make explicit that the result is discarded.

Reply to
Arlet Ottens

Some of us prefer to write a COMMENT, such as // read SCISR1 to clear framoufoob bit, and discard the result


Reply to
Dave Nadler

No need to comment the obvious intention of the code. It's clear that the code is reading SCISR1, and that the result is discarded. So the comment can be:

(void) SCISR1; // clear framoufoob bit

Or even:

clear_framoufoob_bit( );

Reply to
Arlet Ottens

IMO it's useful information that framoufoob bit is cleared by reading the register.

So, nitpicking, the comment should be "reading SCISR1 clears framoufoob".


Oliver Betz, Munich 
despammed.com is broken, use Reply-To:
Reply to
Oliver Betz

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.