3 ms·
How do you get a macro to make an L-value out of a bitfield? That is, it goes on the left of an assignment. I'm doing stuff like this: ethdev->phy.foo = val;
by souprock 7y ago
How do you get a macro to make an L-value out of a bitfield? That is, it goes on the left of an assignment. I'm doing stuff like this:
ethdev->phy.foo = val; // foo is a bitfield in struct phy
cpu->status.irqlevel = newlevel; // irqlevel is a bitfield in the CPU's status word
No, I don't want a 2-argument macro (or worse, with an implied variable) called something like SET_FOO or SET_IRQLEVEL.
Crummy coding guidelines are not a useful argument against the value of bitfields in the C programming language. Coding guidelines can also ban floating-point types, recursion, or symbol names longer than 6 characters. The problem is not C. The problem is the coding guidelines.
- mytailorisrich 7y agoIt's not because you do not understand something and its reasons to exist (though I hinted at them in previous comments) that it is 'crummy'...