LCD Problems (expected an expression)

Hi, i have issues with a function in my program i have to comunicate the LCD with the PIC 16F887, i need help with the syntax,appreciate any help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

  void write_Comando(char X)
{
	char Y;
	Y = X & 0xF0;
	escribir_leer(Y);
	Sleep(2);
	Y |  = 0x4;
	escribir_leer(Y);
	Sleep(2);
	Y &  = 0xFB;
	escribir_leer(Y);
	Sleep(2);
	Y = (X & 0xF) << 4;
	escribir_leer(Y);
	Sleep(2);
	Y&  = 0xFB;
	escribir_leer(Y);
	Sleep(10);
}
> expected an expression
post the full error message, verbatim.

> i need help with the syntax
¿what kind of help?
C++ is very forgiving about whitespace but you can't split an operator with spaces. you have y | = and that is a no-go, jam it together as |=
same goes for &= below it. Because stand alone & and | are operators, it can't get what you mean.

|=, &= etc are compound assignment operators. We can't separate them into two different tokens by placing white space between the two characters that form the operator.

1
2
3
4
5
6
7
8
int main()
{
    unsigned int y = 5 ;

    y |= 4 ; // fine, |= operator

    y | = 4 ; // *** error: expected expression
}

http://coliru.stacked-crooked.com/a/848f5e9b1b7953ff
Topic archived. No new replies allowed.