Show HN: Cmods – a header-only C modules library
github.com
github.com
This is what I made so far. So far, I have only wrapped libc and libm, but I'd love suggestions for other libraries to wrap too.
Other than that, what do you guys think?
What is the benefit over simply including the necessary headers?
Other than the example you mentioned, I don't see much use for it.
All of this is done with essentially identical performance, at least on x86 and x64. (see the readme for details)
As for optimizations of inline functions, I don't include any functions marked static inline, so those will automatically be inlined as before. Meanwhile, link time optimization (LTO) can help with that too.
Also, intrinsic functions might or might not get replaced with inline code, depending on the compiler, thus losing performance.
As for intrinsic functions, I'm familiar with compiler intrinsics, so if you mean those, I don't include those either (well, I can't to be honest, since they don't have symbols in a library). So those will still act as they always have.
Meanwhile, for functions like memset() and such, my experimentation shows (at least on GCC) that it only replaces the call with assembly for smaller values, which I'm guessing are meant for use in tight loops. In places like that, it may be valuable to just use the bare function name.