ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Пятница
26 апреля
341894 Топик полностью
fk0, легенда (20.07.2012 00:18, просмотров: 285) ответил scorpion на лычно я определяю сразу свои типы u8, u16, u32, s8 и т.п. на основе уже имеющихся
Чем это поможет, если половина арифметических выражений в программе начнёт считаться неправильно ввиду того, что при вычислениях разрядность не будет до минимум 16 бит расширяться (integral promotion): 
Integral promotion The C Standard 6.3.1.1: If an int can represent all values of the original type, the value is converted to an int; otherwise, it is converted to an unsigned int. These are called the integral promotions. The integral promotions preserve the value, including the sign. According to 6.3.1.1, a bool, a char, a signed or unsigned char or short int, or an enumeration type is converted to an int or an unsigned int by integral promotion when they are used in expressions. In most cases, this gives the results you would expect mathematically from the expression; for example: char c1,c2,c3; c1=0xA c2=0xB; c3=c1+c2; For a compiler with 16-bit int type, this is, by definition, performed as an int addition, followed by truncating the result to char. 0x0A + 0x0B --> 0x000A+ 0x000B --> 0x0015 --> 0x15.
(C) IAR. Подробная информация в разделе 6.3 ISO 9899 http://embeddedgur …-correct-integer-size/ А за u8 сжигать нужно. По меньшей мере оно даёт раздутый и неэффективный код на CPU с 16/32-битными регистрами.
[ZX]