views:

390

answers:

5

I'm looking for a library for C that gives me at least some of the things I really miss from C++ and the STL/Boost. (I have to use C, so please no "use C++" posts)

I need

  1. dynamic strings (that grow and shrink automatically)
  2. some sort of list (std::vector replacement)
  3. something like stringstream (for type conversations & buffers)

Furthermore, it has to have a mature and Open Source implementation and it has to be platform independant (Windows, Linux and Mac are required to be supported).

Any recommendations?

+14  A: 

What about the GLib from GTK?

Manuel
It looks interesting, do you have any experience with it? Is it usable and not too complicated to get the hang of?
milan1612
Sorry, I do not have any experience with it. AFAIK, The "native" way to wirte programs for GNOME is in C (not C++) with GLIB. Also, the author of the IRC client irssi (http://irssi.org) uses it.So a lot of people are using it (not that this is implies high quality software in every case...)
Manuel
glib is very easy to use. It's very consistent and one of the better "free" software libraries.
Friedrich
Seconded, or whatever. glib is excellent.
unwind
Ok, I think you guys convinced me, glib really seems to be exactly what I want (although quite a nightmare to compile under Windows). Thanks for the suggestion.
milan1612
There are precompiled packages for MSVC if you have some way of using such libraries with your C tool set you don't have to compile it yourself.
Friedrich
+3  A: 

I'd recommend the Apache Portable Runtime. It's reasonably small, portable, and powerful - powers the Apache httpd across multiple platforms, at least.

Thanks for your suggestion.
milan1612
+2  A: 

You could always consider embedding a dynamic language runtime in your application. The Lua core is not large at all, provides data types that meet your requirements, is open source, and MIT licensed so it is compatible with both FOSS and commercial projects.

You wouldn't necessarily need to use code written in Lua to benefit, as its C API provides complete access to its data types and their values. However, you could later move some of the logic of your application into Lua, for the improved clarity of expression and other benefits of coding in a dynamic language with functions as first-class values.

RBerteig
A: 

Ha! The STL and Boost are not mature for C++!

You want a "mature" library that does this for C?

Good luck. C++, STL and Boost are pathetically immature.

(Yeah downvote me, you neophytes.)

smcameron
Hi-larious. I like your blog, even though I find you to be quite offensive at times. Regarding your negative score, your answer does nothing to help the OP's question. I know you can come up with a more informative answer than this.
Tom
Great flamebait.
+1  A: 

Take a look at Gnulib

qrdl