21 March 2015

在读SDCC Compiler User Guide的时候读到下面一段:

bit and sbit types now consistently behave like the C99 _Bool type with respect to type conversion. The most common incompatibility resulting from this change is related to bit toggling idioms, e.g.:

bit b;
b = ~b; /* equivalent to b=1 instead of toggling b */
b = !b; /* toggles b */

In previous versions, both forms would have toggled the bit.



  1. 任何非零的值赋值给_Bool类型的变量bb都会得到值1,而不会像其它unsigned类型的变量一样截取;
  2. 一元操作符~会对其操作数进行整数提升。


blog comments powered by Disqus