Drew DeVault 6/5/2017

Limited "generics" in C without macros or UB

Read Original

This technical article details a C programming pattern that mimics limited generics by using multiple definitions of an incomplete struct type (wlr_output_state) across different modules. It explains how this approach, used in projects like wlroots, reduces reliance on void* pointers for improved type safety and code clarity, while acknowledging its limitations and eventual rollback due to Link Time Optimization (LTO) issues.

Limited "generics" in C without macros or UB

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week