News for hackers. Stuff that matters.
Re:Transmission torrent client ported to C++ by lalaland1125 on Sunday September 12, 2021 @05:38PM (#28505244)
The lack of generics for C makes it difficult to write those sorts of libraries in an efficient way.
Re:Transmission torrent client ported to C++ by klyrs on Sunday September 12, 2021 @11:16PM (#28507518)
C has had generics since C11. Can't fault you for not knowing that, as they're a pain to use and I think folks would rather forget that the language feature exists.
Re:Transmission torrent client ported to C++ by edflsafoiewq on Monday September 13, 2021 @12:08AM (#28507774)
_Generic is basically a switch on typeof(x). Despite the name, it's really a specialization/overloading mechanism.
Re:Transmission torrent client ported to C++ by junon on Monday September 13, 2021 @05:10AM (#28509244)
Those aren't generics, they're more like overloading.
Re:Transmission torrent client ported to C++ by rwmj on Monday September 13, 2021 @03:20AM (#28508706)
I wrote this (slightly crazy) generic vector for C: https://gitlab.com/nbdkit/nbdkit/-/blob/master/common/utils/... If you search for "string" in this page you can see how it is used: https://gitlab.com/nbdkit/nbdkit/-/blob/master/plugins/data/...
Re:Transmission torrent client ported to C++ by ncmncm on Sunday September 12, 2021 @11:11PM (#28507485)
And, generally impossible to write C generics so they may confidently be used safely. There are reasons why C++ was necessary.
Re:Transmission torrent client ported to C++ by tekknik on Monday September 13, 2021 @10:20PM (#28519444)
You’d use a code generator for this, similar to how you’d do it in golang.