Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #168225

Re: Why is glibc not extensive?

From Bart <bc@freeuk.com>
Newsgroups comp.lang.c
Subject Re: Why is glibc not extensive?
Date 2022-11-17 13:57 +0000
Organization Aioe.org NNTP Server
Message-ID <tl5el6$3uq$1@gioia.aioe.org> (permalink)
References <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com> <tl5bi5$laf$1@gioia.aioe.org> <62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>

Show all headers | View raw


On 17/11/2022 13:18, A wrote:
> On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
>> On 17/11/2022 06:31, Amit wrote:
>>
>> Anyway a lot of your suggestions really demand generic solutions, and C
>> doesn't have generic types. For those, there are myriad more assorted
>> ways to add those to C, but the results are usually ungainly and painful
>> to use.
>>
>> C is just not suited for such things.
> 
> Generics can be implemented in C without much hassle.
> 
> I am currently implementing C++ STL in C. And the my data structures are generic - any type of data can be used just like in C++ STL.

As I said, lots of people have attemted this. If I tried it, I would do 
it differently from your, with different trade-offs. Which one should 
standard C have?

> 
> The following is part of my header file which lists how I achieved generics in C:
> 
>   struct element
> {
>      void *data;
>      long data_len;
>      struct element *next;
> };
>                                                                                   
> typedef void (*call_function_before_deleting_data)(struct element *);
> typedef void (*compare_elements_function)(struct element *, struct element *);
>                                                                                   
> struct generic_unordered_set_container
> {
>      struct element *first;
>      struct element *fi; // fi stands for forward iterator
>      long total_number_of_elements;
>      // callback functions
>      call_function_before_deleting_data cfbdd_callback_function;


>      compare_elements_function ce_function;
>      // to be thread-safe
>      pthread_mutex_t mtx;
>      pthread_mutexattr_t mtx_attr;
> };

What does an example of use actually look like, compared with C++?

C++ has famously long-winded and 'busy' syntax; is yours going to be 
longer or shorter?

And why would somebody use this particular library, in C, compared to 
just using C++?

For example, a simple array like this:

    vector<int> A = {10,20,30,40};

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Why is glibc not extensive? Amit <amitchoudhary0523@gmail.com> - 2022-11-16 22:31 -0800
  Re: Why is glibc not extensive? Bart <bc@freeuk.com> - 2022-11-17 13:05 +0000
    Re: Why is glibc not extensive? A <amit234234234234@gmail.com> - 2022-11-17 05:18 -0800
      Re: Why is glibc not extensive? A <amit234234234234@gmail.com> - 2022-11-17 05:24 -0800
      Re: Why is glibc not extensive? Bart <bc@freeuk.com> - 2022-11-17 13:57 +0000
      Re: Why is glibc not extensive? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-11-17 17:04 +0000
      Re: Why is glibc not extensive? David Brown <david.brown@hesbynett.no> - 2022-11-18 09:32 +0100
        Re: Why is glibc not extensive? A <amit234234234234@gmail.com> - 2022-11-18 02:32 -0800
          Re: Why is glibc not extensive? David Brown <david.brown@hesbynett.no> - 2022-11-18 13:09 +0100
            Re: Why is glibc not extensive? A <amit234234234234@gmail.com> - 2022-11-18 04:47 -0800
              Re: Why is glibc not extensive? David Brown <david.brown@hesbynett.no> - 2022-11-18 13:59 +0100
                Re: Why is glibc not extensive? A <amit234234234234@gmail.com> - 2022-11-18 05:27 -0800
              Re: Why is glibc not extensive? Bart <bc@freeuk.com> - 2022-11-18 17:04 +0000
                Re: Why is glibc not extensive? David Brown <david.brown@hesbynett.no> - 2022-11-21 08:50 +0100
                Bart (Was: Why is glibc not extensive?) gazelle@shell.xmission.com (Kenny McCormack) - 2022-11-21 14:14 +0000
              Re: Why is glibc not extensive? Michael S <already5chosen@yahoo.com> - 2022-11-21 08:10 -0800
                Re: Why is glibc not extensive? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-11-26 09:07 -0800
                Re: Why is glibc not extensive? Michael S <already5chosen@yahoo.com> - 2022-11-26 16:11 -0800
                Re: Why is glibc not extensive? Kaz Kylheku <864-117-4973@kylheku.com> - 2022-11-27 13:05 +0000
                Re: Why is glibc not extensive? scott@slp53.sl.home (Scott Lurndal) - 2022-11-27 16:30 +0000
                Re: Why is glibc not extensive? BGB <cr88192@gmail.com> - 2022-11-27 12:20 -0600
                Re: Why is glibc not extensive? Bart <bc@freeuk.com> - 2022-11-27 21:13 +0000
                Re: Why is glibc not extensive? BGB <cr88192@gmail.com> - 2022-11-27 21:53 -0600
                Re: Why is glibc not extensive? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-03 01:17 -0800
        Re: Why is glibc not extensive? BGB <cr88192@gmail.com> - 2022-11-23 15:11 -0600
  Re: Why is glibc not extensive? Bonita Montero <Bonita.Montero@gmail.com> - 2022-11-17 19:05 +0100
    Re: Why is glibc not extensive? gazelle@shell.xmission.com (Kenny McCormack) - 2022-11-18 08:09 +0000
      Re: Why is glibc not extensive? BGB <cr88192@gmail.com> - 2022-11-23 13:55 -0600

csiph-web