[an error occurred while processing this directive] [an error occurred while processing this directive]
а про индейцев забыли ! (типа если переносимость нужна)
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)
[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive]

Отправлено yes 10 декабря 2001 г. 14:59
В ответ на: в общем случае так нельзя отправлено VZ 10 декабря 2001 г. 14:48

#undef DOUBLE_ENDIANNESS
#if defined(__i386__) || (defined(__PPC__) && defined(__LITTLE_ENDIAN__))
#define DOUBLE_ENDIANNESS 0
#elif defined(__PPC__) && defined(__BIG_ENDIAN__)
#define DOUBLE_ENDIANNESS 1
#else
#error "Don't know words ordering in 'double' type"
#endif

#undef IDX1
#undef IDX2
#if DOUBLE_ENDIANNESS == 0
#define IDX1 0
#define IDX2 1
#elif DOUBLE_ENDIANNESS == 1
#define IDX1 1
#define IDX2 0
#else
#error "Unsupported value for bytes order in doubles"
#endif

-------------
ну и дальше

union { F8 f8; U4 u4[2]; } u;
u.u4[IDX1] = getU4();
u.u4[IDX2] = getU4();

Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru