A technique for achieving limited generic-like behavior in C without macros or undefined behavior, using multiple definitions of an incomplete struct type. By leaving a struct (wlr_output_state) undefined in shared headers and letting each backend define it privately, implementations avoid void* casting and gain type safety. The approach is demonstrated with the wlroots compositor library's output backend system. Note: the author later rolled back this pattern due to LTO (link-time optimization) incompatibilities.
Sort: