Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
doomrobo
on March 13, 2015
|
parent
|
context
|
favorite
| on:
Klib: A standalone and lightweight glib
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.
tbirdz
on March 13, 2015
|
next
[–]
There is also the approach used for linked lists in the Linux Kernel:
http://kernelnewbies.org/FAQ/LinkedLists
zem
on March 14, 2015
|
prev
|
next
[–]
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.
faragon
on March 13, 2015
|
prev
[–]
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: