Top
Best
New

Posted by ingve 6/27/2025

Parameterized types in C using the new tag compatibility rule(nullprogram.com)
154 points | 95 commentspage 2
tialaramex 6/27/2025||
It seems as though this makes it impossible to do the new-type paradigm in C23 ? If Goose and Beaver differ only in their name, C now thinks they're the same type so too bad we can tell a Beaver to fly even though we deliberately required a Goose ?
yorwba 6/27/2025|
"Tag compatibility" means that the name has to be the same. The issue the proposal is trying to address is that "struct Goose { float weight; }" and "struct Goose { float weight; }" are different types if declared in different locations of the same translation unit, but the same if declared in different translation units. With tag compatibility, they would always be treated as being the same.

"struct Goose { float weight; }" and "struct Beaver { float weight; }" would remain incompatible, as would "struct { float weight; }" and "struct { float weight; }" (since they're declared without tags.)

tialaramex 6/27/2025||
Ah, thanks, that makes sense.