Ok, so it seems that more people have selected B than A. This slightly surprises me because most of the places that I have worked use 'A' (not on my advice), but then that was why I asked. But as someone has pointed out the experience of the posters to the group is above the average so that should be the reason.
The actual question was an interview question (asked to a colleague). It was a telephone interview so there was little scope for discussion.
Those of you who answered "it depends" have failed (my decision) as the code requirement is one of 'conformity' and 'reusability' from one project to the next (and reusability of the programmer's knowledge from one project to the next).
I suppose those that have answered 'something else' would not have done so in an interview (unless they had already decided that they didn't want the job) and can decide for themselves if they 'passed'. Feel free to disagree with this assumption if you really would argue the point in a telephone interview (which here is a filter into a 'real' interview).
The answer that the interviewer wanted was 'b'. So those people pass (as long as they get the other questions correct!)
My colleague was pissed, as he said 'a', on no more experience than what we do currently. He asked me the question, I instantly said 'b' and when asked why I said "because bits are not portable" (correct answer - been there..., to be avoided big time) which pissed him off even more.
But on reflection perhaps he has a right to be pissed. IME many people don't know that bits are not portable (or perhaps they decide that they don't care), but they still might prefer Option 'b' because:
1) they consider it neater SetBit( ®ister_name, bit_name ); is a arguably tidier than register_name->bits.bit_name = 1;
2) It can provide error checking missed by some compilers, which don't object if you try to put more bits into the element than it actually has.
3) It can provide a uniform interface with reading bits from locations that are not accessed by a single read such as the register on an I2C device for which the struct method will not work automatically.
(and some, who know bits aren't portable, might still prefer 'a', though god knows why!)
So if the interviewer just wanted to find out if the interviewee knew that bits aren't portable he should have asked using a less roundabout question to establish this and addressed the 'style' issues separately (which I am sure my colleague would have got right).
Anyone care to comment?
tim