hi all, I have the following line in my code: PortVal << 1; When I compile using c51 v6.12, I get the following warning assocaiated with that line: "warning C275: expression with possibly no effect" When I load this into my emulator, "PortVal << 1" has been optimized away. I know that << 1 is the same as *2, and when I use *2, the compilier is happy, but I like << 1 because it helps readability..... Does anyone know why << 1 causes that warning or how to prevent it from being optimized away? Thanks Steve
Your right....my bad....typo in my email. The line is written PortVal *= 2. Thats why the compilier doesnt complain. I agree that if it was *2, the compiler would point that out to me. I just looked in "C The Complete Reference" and they dont show this construct as <<= either; they just show it as <<. Hmmmm. Interesting. Anyway, thanks again for all the help.
"<<" is an operator, the same as "*". So var = var * 2 is the same as var *= 2 and var = var << 1 is the same as var <<= 1