== vs =

Barnacle Wes wes at obie.UUCP
Sat Apr 9 02:26:55 AEST 1988


In article <226 at hotlr.ATT>, dkc at hotlr.ATT (Dave Cornutt) writes:
> [...]                               D is another matter; catching the
> accidental misapplication of "=" in "if" statements would be worth it.

The one thing that everyone seems to have forgotten in this discussion
is that `=' is NOT always invalid in and if clause:

volatile short *statreg = (short *) 0x00FFC000L;
...
    short status;
    ...
    if (status = *statreg) {
	do something with status;
    }

Code like this would (perhaps) be used for polling hardware status
registers.  Remember, C is supposed to be a general-purpose language!
-- 
    /\              -  "Against Stupidity,  -    {backbones}!
   /\/\  .    /\    -  The Gods Themselves  -  utah-cs!utah-gr!
  /    \/ \/\/  \   -   Contend in Vain."   -  uplherc!sp7040!
 / U i n T e c h \  -       Schiller        -     obie!wes



More information about the Comp.lang.c mailing list