NO

Author Topic: Container libraries  (Read 412 times)

Offline CandCPlusPlus

  • Member
  • *
  • Posts: 39
Container libraries
« on: August 26, 2022, 10:17:20 pm »
I'm rather curious about what people on here typically use in C for containers and I'm wondering if there are any simple and lightweight open source container libraries for C that you can use for C++ like containers

Personally, when I use containers in C++, it seems like I use std::vector 90% of time, maybe std::map 8% or 9% of time and everything else I only use in niche cases. I have read about creating dynamic arrays and creating functions to manipulate them in C and it looks moderately easy to accomplish. However, I tend to think that there's always the chance of bugs when creating it yourself, especially if it's more sophisticated vs. simply including possibly very well tested containers/container libraries in your project.
« Last Edit: August 27, 2022, 07:22:15 pm by CandCPlusPlus »

Offline MrBcx

  • Global Moderator
  • Member
  • *****
  • Posts: 100
    • Bcx Basic to C/C++ Translator
Re: Container libraries
« Reply #1 on: August 27, 2022, 02:54:23 am »
I've never used it and I don't know whether it depends on any Lcc-Win32 extensions  that may not exist in Pelles C but Jacob Navia shared a containers library about 10 years ago that could be a jumping off point for you.

https://code.google.com/archive/p/ccl/downloads


Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1996
Re: Container libraries
« Reply #2 on: August 27, 2022, 09:37:12 am »
problems with ccl source files
bloom.c
list.c

May the source be with you

Offline John Z

  • Member
  • *
  • Posts: 482
Re: Container libraries
« Reply #3 on: August 27, 2022, 11:16:31 am »
Hi CandCPlusPlus,

Searching the web there are several to choose from, here is a possibly useful link too

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1625.pdf

To C or not to C++ that is the question . . .

I think one is best served learning C without trying to turn it into C++ at the outset.  After a good foundation in C is acquired then adding C++ abstractions back to the toolkit is a better approach  IMO.

Having said the above here is a another possibly useful link to a lib with frequent mentions

https://docs.gtk.org/glib/ 

John Z

Offline CandCPlusPlus

  • Member
  • *
  • Posts: 39
Re: Container libraries
« Reply #4 on: August 28, 2022, 06:11:04 pm »
I found several rather promising libraries on github, especially the STC one. I do also agree to a certain degree with John Z. I probably should experiment with the native C functions more and learn those well. It's probably wise to do so.

The STC one even has a wrapper for strings. It definitely makes C have C++ like containers and such. O.O With this library being fully C99 compliant it should, in theory, work in Pelles C.

I'll post the links for everyone else.
STC - Smart Template Containers for C
https://github.com/tylov/STC

Containers
https://github.com/bkthomps/Containers

I think one is best served learning C without trying to turn it into C++ at the outset.  After a good foundation in C is acquired then adding C++ abstractions back to the toolkit is a better approach  IMO.
« Last Edit: August 28, 2022, 06:47:32 pm by CandCPlusPlus »