/*
* U32TO8_BIG(c, v) stores the 32-bit-value v in big-endian convention
* into the unsigned char array pointed to by c.
*/
#define U32TO8_BIG(c, v) do { \
u32 x = (v); \
u8 *d = (c); \
d[0] = T8(x >> 24); \
d[1] = T8(x >> 16); \
d[2] = T8(x >> 8); \
d[3] = T8(x); \
} while (0)
/*
* U32TO8_LITTLE(c, v) stores the 32-bit-value v in little-endian convention
* into the unsigned char array pointed to by c.
*/
#define U32TO8_LITTLE(c, v) do { \
u32 x = (v); \
u8 *d = (c); \
d[0] = T8(x); \
d[1] = T8(x >> 8); \
d[2] = T8(x >> 16); \
d[3] = T8(x >> 24); \
} while (0)
Showing posts with label C Programming. Show all posts
Showing posts with label C Programming. Show all posts
Saturday, October 24, 2009
U32-to-U8 conversion
Thursday, May 07, 2009
[C Programming] Difference between const int* and int* const
const int* - a variable pointer pointing to a constant integer.
int* const - a constant pointer pointing to a variable integer.
E.g.
int i = 7;
const int* p = &i;
*p = 8; //ERROR!
* The trick is to read from right to left. :)
Subscribe to:
Posts (Atom)