Data Structure Library for C

This is a discussion on Data Structure Library for C within the C Programming forums, part of the General Programming Boards category; It is easy to find some packages for data structures such as list, heap, etc on Internet. There is a ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    98

    Data Structure Library for C

    It is easy to find some packages for data structures such as list, heap, etc on Internet. There is a GNU libavl for balanced binary trees. However, there is no GNU package for lists etc (see http://directory.fsf.org/GNU/). Are there too many already that people do not bother to contribute one to GNU? I may be wrong, but being on the GNU list somwhat lends credibility to a library. Can anyone recommend a good, or widely used, library for data structures such as lists and queues? I do not want to reinvent the wheel; on the other hand, I want something reputable. Thanks.
    Last edited by hzmonte; 11-14-2005 at 11:01 PM.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    C++ was one solution. Is this out of the realm of possibility?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    98
    I want something that can be called by my C program. Can one call STL from a C program? Just curious, why is there a STL for C++ but not C?

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Well, for one there is no T in STL for C. And another might be that C++ was this solution. But there may be ways that others may be better at addressing the part about being C callable. Perhaps there are simple methods that allow a C++ interface from C, but I'm no authority.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    868
    Quote Originally Posted by hzmonte
    Can one call STL from a C program?
    No.

    Edit: elaboration:

    Generally there are compiler specific methods for linking in C++ library calls to C code, but obviously when you start using C++ template semantics, you are no longer writing C code.

    Just curious, why is there a STL for C++ but not C?
    Because the STL uses templates, and C doesn't support templates, so the real question is "Why doesn't C support templates?". The answer is probably because C is not C++.

    Edit: Too late.

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >I do not want to reinvent the wheel
    That's admirable, but most uses of lists and queues and stacks and such are too simple to warrant a library (it seems), so programmers will take an ad hoc approach to it 9 times out of 10. I find that it's faster and cleaner to do it myself and not worry about some overly generic library cluttering up my code.

    Now for more sophisticated data structures, a good library can save you oodles of time that could be better spent playing video games.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pthread question how would I init this data structure?
    By mr_coffee in forum C Programming
    Replies: 2
    Last Post: 02-23-2009, 11:42 AM
  2. static data structure in a library
    By melight in forum C Programming
    Replies: 6
    Last Post: 01-10-2009, 10:12 AM
  3. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  4. can't insert data into my B-Tree class structure
    By daluu in forum C++ Programming
    Replies: 0
    Last Post: 12-05-2002, 05:03 PM
  5. Dynamic Data Structure -- Which one is better?
    By Yin in forum C++ Programming
    Replies: 0
    Last Post: 04-10-2002, 11:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21