Jump to content

Problem with UNARY operator

Recommended Posts

The compiler is having a problem with the UNARY operator in the following piece of Code:




 char i = 0;


 gpio |= LE;             // set the bit, raising LE HIGH

 gpio &= !LE;           // bring LE low again, data is latched



When the last line is compiled into the code, an error message is generated reading;

"Unexpected UNAR operation". If you remove the last line, then the code compiles without errors. This is a BUG, and would like to know when a fix could be available. This is a pretty common operation in embedded programming and with out it, coding is useless.



Jerry Mulchin

Link to post
Share on other sites

Here is my $0.02...


The "!" operator is used to invert the results of a logical

operation, like ... if ( x != 55 ).  The result of using "!" is

either false (0x00), or true (0x01).


To invert the individual bits in a bit-mask, like your example,

you would use the "~" operator...  gpio &= ~LE;


I hope this helps.


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...