Re:The Curious Case of the Longevity of C
by kibwen on Tuesday October 03, 2017 @06:11AM
(#15391336)
Speaking of the C preprocessor, I found this recently: from the Firefox source code, a red-black tree written entirely in 800 lines of C macros: http://searchfox.org/mozilla-central/rev/f54c1723befe6bcc722... . Submitted for your enjoyment. :)
[ Parent
| on HN ]
Re:The Curious Case of the Longevity of C
by naasking on Tuesday October 03, 2017 @10:08AM
(#15392502)
There are whole libraries that provide these sorts of generic containers for C:
Re:The Curious Case of the Longevity of C
by jstewartmobile on Tuesday October 03, 2017 @06:33AM
(#15391416)
I've used OpenBSD's version of that more times than I care to remember: http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/...
Re:The Curious Case of the Longevity of C
by nikbackm on Tuesday October 03, 2017 @07:30AM
(#15391627)
Looks to be some small amount of C code in those macros as well.
Re:The Curious Case of the Longevity of C
by throwme211345 on Tuesday October 03, 2017 @09:34AM
(#15392259)
Why would someone do that?
Re:The Curious Case of the Longevity of C
by dboreham on Tuesday October 03, 2017 @11:24AM
(#15392998)
Because long ago (and probably in a different product) making a function call was significantly costly and worthwhile optimizing away via macros.
Re:The Curious Case of the Longevity of C
by jstewartmobile on Tuesday October 03, 2017 @04:39PM
(#15395969)
That is how we do "generics" in C. Not happy about it, just sayin'.