4 ms·
I "abuse" unions and anonymous unions all the time, it's very practical, and make the 'user' code a lot clearer as you can access the small 'namespace' as conve
by buserror 3y ago
I "abuse" unions and anonymous unions all the time, it's very practical, and make the 'user' code a lot clearer as you can access the small 'namespace' as convenient.
Here for example I can access it as named coordinates, x,y points or a vector.
typedef union c2_rect_t {
struct {
c2_pt_t tl, br;
};
c2_coord_t v[4];
struct {
c2_coord_t l,t,r,b;
};
} c2_rect_t;
- trentnelson 3y ago100% agree! I use whatever tool in the C toolbox results in the easiest-to-(read|grok) code, which means tons of anonymous union/struct “abuse”, bit fields, function pointer typedefs, strictly adhering to “Cutler Normal Form”.
- bruce343434 3y agoWhat is "Cutler Normal Form"?
- synergy20 3y agoconfused by the code,can you elaborate more