HITECH C compiler error

Discussion in 'Programmer's Corner' started by Strathspey, Mar 15, 2011.

  1. Strathspey

    Thread Starter New Member

    Mar 15, 2011
    1
    0
    Could somebody please explain the following compiler error:
    160. constant operand to || or &&

    which points to the following line of code:
    LCD_DATA = cmd && 1; /* set RS bit, 1 == data, 0 == command */

    Thanks in advance
    Pat
     
  2. someonesdad

    Senior Member

    Jul 7, 2009
    1,585
    141
    It probably should be a warning, not an error (compiler writer's choice). You need to understand the difference between the && and & binary operators. You probably meant &, not &&.
     
  3. nigelwright7557

    Senior Member

    May 10, 2008
    487
    71
    & is a bitwise AND.
    && is a logical AND.
     
Loading...