Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
codr7
23 days ago
|
parent
|
context
|
favorite
| on:
How to write generics in C
No. You don't mess around with the language like that.
This is how you do it:
https://github.com/codr7/hacktical-c/tree/main/vector
xigoi
23 days ago
[–]
This is the type erasure approach, whose cons are mentioned in the article.
codr7
22 days ago
|
parent
[–]
It's the C approach, strong typing doesn't mix well with raw memory access.
1718627440
22 days ago
|
root
|
parent
|
next
[–]
The very article we are discussing shows you a way how to do that type safely in C. It uses #include which is a very idiomatic way to do this in C, and an example where a preprocessor-based approach is more flexible, than e.g. a module system.
xigoi
22 days ago
|
root
|
parent
|
prev
[–]
Nim is strongly typed and allows raw memory access just fine.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
This is how you do it:
https://github.com/codr7/hacktical-c/tree/main/vector