Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think that macros are the only real option if you want to have an interface for multiple types and still have some semblance of type-safety. The only alternative I can think of is writing code that takes void* everywhere.


There is also the approach used for linked lists in the Linux Kernel: http://kernelnewbies.org/FAQ/LinkedLists


the third option is to write your code in some more type-safe language (heck, even c++) and add extern c wrappers around all your exposed functions.


Yes. But the "void *" everywhere code would take just a portion of the space, as for every different type, you would be duplicating the code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: