r/C_Programming • u/tavianator • 2d ago
Tidy translucent typedefs
https://tavianator.com/2026/translucent_2.htmlRecently discovered a nice way to get custom warnings with Clang, so I wrote it up.
34
Upvotes
7
u/Accurate_Appeal_3110 2d ago
This is really neat! Could be really useful on enums to prevent implicit conversions to and from its underlying type, like C++'s enum classes
1
u/bacmod 1d ago
Give me a source to run it.
2
u/tstanisl 1d ago
Interesting.
I've been looking for a way to annotate types with some form of attributes to express additional semantics like "owned", "sized", "stb_vector", etc. And some means of defining rules if the gaining/dropping attribute requires an explicit cast. I hoped to find some popular extensions but I could not find a good one. Using alignment requirements is definitely a bit scary hack but it gets job done for most cases. thank you