Hacker GitHub

← All repos

glouw/ctl

View on GitHub ↗ ★ 1,382 C

The C Template Library

22 mentions on Hacker News by 8 people: 1 story, 21 comments · first 2020-10-25 · latest 2025-06-27

Mentions per year 22 mentions · busiest year 2021 (10)
20082026
  1. …whole files "parameterized" by their macro environment like https://github.com/c-blake/bst or https://github.com/glouw/ctl/ Add a namespacing macro and you have a whole generics system, unlike that in TFA. So, it might add more value to…
  2. Probably worth mentioning the C Template Library [1]... [1]: https://github.com/glouw/ctl/
    comment by spacedcowboy · 2025-03-19 · in Implementing Generic Types in C
  3. Maybe not it, but STC ( https://github.com/tylov/STC ) and CTL ( https://github.com/glouw/ctl ) both use this define method for creating data structures and linking up compare functions for them.
  4. …C++, with a little (reasonable) preprocessor abuse. It gives great cache contiguous results: https://www.github.com/glouw/ctl
    comment by glouwbug · 2022-05-17 · in Common libraries and data structures for C
  5. While I agree the common pattern is to use void*/dynamic dispatch, this is not necessary. E.g., https://github.com/glouw/ctl/ or https://github.com/c-blake/bst show a couple ways to have generic code statically specialized in regular old…
  6. …while maintaining compile time type safety and gaining speed and maintainability looks something like this: github.com/glouw/ctl Check CTL/vec.h, for instance
  7. CTL. https://github.com/glouw/ctl It's functionally blackbox compatible with the STL for the major containers. Unless you're writing heap spaced firmware where C++ with an STL isn't available I recommend you just use modern day C++.…
  8. …like it as far as I know. The closest alternative is CTL but it doesn't have any of those features: https://github.com/glouw/ctl/
  9. …previous implementations. The two I’ve found more interesting are: - “C Template Library (CTL)”: https://github.com/glouw/ctl - “Klib: a Generic Library in C”: https://github.com/attractivechaos/klib/
    comment by AlbertoGP · 2021-04-23 · in Beej’s Guide to C Programming [pdf]
  10. …library, one that tries to more directly port C++ templates to C but with a lot less features: https://github.com/glouw/ctl/
    comment by ludocode · 2021-04-09 · in Type-safe generic data structures in C
  11. https://github.com/glouw/ctl/
    comment by cb321 · 2021-03-13 · in Speed of Rust vs. C
  12. …to think. This is probably largely why @mehrdadn's original article had the title it did. ;-) } [1] https://github.com/glouw/ctl/ [2] https://nim-lang.org
  13. Ye, I pushed it to the extreme and back ported a good chunk of the STL to C: https://www.github.com/glouw/ctl
    comment by glouwbug · 2021-01-23 · in C++ Anti-Patterns
  14. Eh, even C supports clean templated type safe containers: https://www.github.com/glouw/ctl Why Go is so far behind is behind me
    comment by glouwbug · 2021-01-13 · in A Proposal for Adding Generics to Go
  15. …to int compare(int, int) when P is defined? I wonder if it impacts at all the benchmarks. [1] https://github.com/glouw/ctl/blob/49b90312f9473057fd2ed77941...
    comment by teabee89 · 2020-12-30 · in C Template Library
  16. Yes, as many templates as you like. An A* pathfinder, for instance: https://github.com/glouw/ctl/blob/master/examples/astar.c#L8... Although if you're interested in just a batch rename, it's something like this: #define vec_char str…
    comment by glouwbug · 2020-12-30 · in C Template Library
  17. …possibly "cloning" to do the same, which is less likely for a complicated algorithm like sort. [1] https://github.com/glouw/ctl/blob/09f5e0a89d3fc621aff94290c4... edit: I wonder how ctl's vector sort compares to qsort, I expect it to be…
    comment by leni536 · 2020-12-30 · in C Template Library
  18. …6502 compiler. I have also written a small wiki, that showcases how to use the included containers: https://github.com/glouw/ctl/wiki
    comment by glouwbug · 2020-12-29 · in C Template Library
  19. ▲ 266
    C Template Library
    story by glouwbug · 2020-12-29 · 128 comments
  20. …porting parts of the C++ STL to C, so it may have a dictionary type now, depending on who you ask! https://github.com/glouw/ctl
  21. I've been working on this which you might find of use: https://github.com/glouw/ctl
    comment by glouwbug · 2020-12-17 · in Getting started with C
  22. If anyone is interested, I'm in the process of back porting the STL to C99: https://github.com/glouw/ctl The gist of its workings is including a header and defining its type: #define T int #include <vec.h> #define T float #include <lst.h>…
    comment by glouwbug · 2020-10-25 · in What's Wrong with C++ Templates? (2003)