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

1
The Beautiful Web
Jens Oliver Meiert 2 votes
3
LLM Use in the Python Source Code
Miguel Grinberg 1 votes
4
Wagon’s algorithm in Python
John D. Cook 1 votes