3 ms·
isn't the ordering of bitfields undefined, therefore useless when trying to map out register bitflags? I just end up creating configuration structs and mapping
by bfrog 8y ago
isn't the ordering of bitfields undefined, therefore useless when trying to map out register bitflags?
I just end up creating configuration structs and mapping those to/from register values in some get/set functions as needed
- ChuckMcM 8y agoNo, the ordering of bitfields is implementation defined rather than undefined. So if you figure out a bitfield pattern that works on your compiler for your architecture it will continue to work for you. It is not very portable but for embedded applications that often isn't a problem.
- keithnz 8y agoalso, given this is "Embedded" C, the compilers often provide libs to target micros with bitfields, so it has a known definition.
- tzahola 8y ago>So if you figure out a bitfield pattern that works on your compiler More like: if your compiler is documented to implement bitfields a certain way.
- geofft 8y agoIt is also not portable to new versions of the same compiler, or possibly different flags passed to the same compiler and version.