in reply to [Way OT] C: Arrays of bitfields? (Updated:Please ignore!)

Hi BrowserUk,

I think you cannot do that in C. But you can use macro to hide the messy expression:

#define getsextet(UV, I) (( (UV) & ( 0x7f << (6*(I)) ) >> 6*(I))
and the appropriate 'set' and 'clr':
#define clrsextet(UV, I) ( (UV) & ~( 0x7f << (6*(I)) ) #define setsextet(UV, I, S) ( (UV) | ( ((S) & 0x7f) << (6*(I)) )
The sextet have to be cleared before set. I haven't had time to test these macros, please use them carefully.

Replies are listed 'Best First'.
Re^2: [Way OT] C: Arrays of bitfields?
by BrowserUk (Patriarch) on Jan 18, 2015 at 09:39 UTC
    But you can ... hide the messy expression:

    Indeed. Though I'll probably opt for inlined functions.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked