10

C++ has STL and Boost and C# has the .net Framework library. Similarly, what are the most common libraries useful to a C programmer? (Other than the C standard library.)

I am looking for most of the capabilities available in the STL: containers (vectors, linked lists, trees, hash table), algorithms (sorting, searching), file IO and strings.

Ideally, the library should be open-source, work on Windows (cross-platform is fine) and is being used actively.

Ashwin Nanjappa
  • 76,204
  • 83
  • 211
  • 292

3 Answers3

7

If you want general-purpose data-structures like STL has, glib is probably the answer to your question. But a better question might be why are you writing your program in C? C's potential to shine comes when you don't use overly-general code to perform tasks that could be better performed in ways specific to your particular task at hand. glib just gives you "C++ with ugly syntax" (and less ability for the compiler to optimize).

R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
  • For such a large framework glib and gtk are well done. I would not like ot have yet another C++ dialect for that. And C++ as "having" a nice syntax is well adventurous. – Friedrich Feb 14 '11 at 06:42
  • 2
    I'm not a fan of C++ or its syntax, but I'm also not a fan of trying to make C a C++ work-alike. Most of the advantage of C comes from the fact that you can avoid dynamic allocation entirely for intermediate operations and only allocate long-lived objects. – R.. GitHub STOP HELPING ICE Feb 14 '11 at 06:47
5

The closest I know if is glib from GTK, see http://library.gnome.org/devel/glib/2.26/

Toby
  • 2,039
  • 1
  • 13
  • 10
1

Yes. GLib is the closest thing to STL in C. If you find it quite complex to use, try Vala. It is much easier. http://live.gnome.org/Vala

Harish
  • 228
  • 1
  • 7
  • Vala looks pretty neat, looks basically like writing C# but compiling to native C code/binary, though I don't think it should apply to this question. – Earlz Feb 14 '11 at 05:19