Is char restricted to 8 bits? If not, maybe this is more general:
No, char is not restricted to 8 bits, it can't be less buy may be
more. I routinely work on C implementations for DSPs where chars have
#define nyb_u(a) (((a)>>(sizeof(a)*8-4))&0x0F)
Uh, no, while char is not limited to 8 bits, it is limited to being
exactly one byte. sizeof(char) is 1 by definition in C, always has
been, always will be. Even if char contains more than one octet,
which is the proper term for a collection of exactly 8 bits.
So your expression is exactly equivalent to Rod's.
If you want to be truly portable and get the lowest 4 bits and highest
4 bits out of a character, you need to do this:
#define myb_u(a) (((a)>>(CHAR_BIT-4))&0x0f)
....if I counted the parentheses correctly.
On a Texas Instruments TMS320F2812, that would give you bits 15
through 12 of the 16-bit char.