ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Четверг
11 июля
389875 Топик полностью
RedFroggy (22.02.2013 10:25, просмотров: 77) ответил SciFi на Всё правильно кейл сделал. А бороться так: Var1 = (unsigned char)buff[2] + 4;
Возможно, это ошибка из разряда таких (из последнего Release Note): Corrected: calculation of negative constants within nested calls may create incorrect results (this problem was introduced in C51 V9.50a). For example: #define TDO 5 #define GET_TDO() (Arr[TDO]) unsigned char xdata Arr[10]; unsigned char TestTDO() { unsigned char ret; ret = (unsigned char)(((GET_TDO()-1)*2)-1); // Incorrect result. For the negative constant a subtraction has been used instead of an addition. return ret; } Corrected: incorrect pointer arithmetic with subtract of unsigned int variables for XDATA arrays with sizeof < 256 bytes. For example: unsigned char xdata b[256]; /* Problem does not exist when array size > 256 */ void xdata *p; unsigned int i = 256; /* Problem only appears for unsigned int variables */ void main (void) { p = &b[256-i]; /* Works no problem when array index is used */ p = b + 256 - i; /* Failed on pointer arithmetic when uint variable is subtracted */ } Var1 - это поле структуры. Указатель на глобальную переменную структуры также передаётся в функцию f1(my_struct *obj, char* buff)ж obj->Var1 = buff[2] + 4; такой код на самом деле, хотя разницы я не вижу от самого первого топика