7 ms·
What do you use then if you don't use the standard library? What is the standard library for the C which ends all the other standards libs?
by bhaak 6y ago
What do you use then if you don't use the standard library?
What is the standard library for the C which ends all the other standards libs?
- adrift 6y agoYour own.
- flohofwoe 6y agoFor IO, memory management and similar "low-level services" it's often fine to call the underlying operating system functions directly and with this also make use of more powerful features than the standard library can provide, such as async IO, virtual memory etc (or wrap those OS calls into your own cross-platform wrapper functions). There's also plenty of libraries which do this for you, like libuv (but integrating such big libs is often not trivial). Same for string handling/processing, there are specialized libraries out there which do a specific job better than the rather generic standard library functions (this is also true for the C++ stdlib), one just has to find those libraries. PS: I don't think that a "batteries included" standard library (like python has) would even make sense for C, such a library would need to be opinionated by definition, better to keep (too many) opinions out of the standard, as this road just leads to another C++ ;)
- arcticbull 6y agoC++ is IMO defined by a complete lack of opinion. They just standardized every opinion. For everything. C++ would be a much better language if it showed some opinion, even if I disagreed with it.
- anfilt 6y agoThat's honestly how I also feel about C++ in when I look at how often they are adding new things.
- asveikau 6y ago> Same for string handling/processing, there are specialized libraries out there which do a specific job better I actually can't think of a lot of these that are super common across projects. ICU is probably the most notable one, with its particular focus on unicode correctness. A lot of large projects end up writing their own string library of sorts.
- bigbubba 6y agoThere's bstr, I've come across that a few times.
- WalterBright 6y agoIn my long C career, I invented string library after string library. They all turned out to be garbage. The common cause of their failures is their inability to interact with any other C code.
- flohofwoe 6y agoAgreed, but that's an issue for all "interface types" on API boundaries (another similar issue is vector and matrix types in math libraries). IMHO a C string library must still be able to efficiently consume and produce vanilla zero-terminated "const char*" string data (and at a stable address, unlike for instance std::string) even if they mostly work with {pointer,length} ranges internally.
- WalterBright 6y agoC strings are so ubiquitous that the ABI impedance mismatch is just too annoying.
- einpoklum 6y agoYou can use something like GitHub or Conan to find specific useful C libraries. There isn't a universally recognized "standard library replacement" (and people argue about what parts of the standard library they don't like), but here: https://stackoverflow.com/questions/486383/safer-alternatives-to-the-c-standard-library https://stackoverflow.com/questions/486383/safer-alternative... are a few options: * Glib (the basis for Gtk): https://developer.gnome.org/glib/stable/glib.html https://developer.gnome.org/glib/stable/glib.html * The Apache Portable Runtime (APR): http://apr.apache.org/ http://apr.apache.org/ Caveat: I haven't used them.
- 1vuio0pswjnm7 6y agodjb's libraries (answer to first question)