NO

Author Topic: Can I get some feedback on a library I made for creating dynamic arrays in C?  (Read 7728 times)

NateSeymour

  • Guest

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Seems promising...  :)
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

NateSeymour

  • Guest
Seems promising...  :)
Thank you very much :)

Gesendet von meinem Pixel mit Tapatalk


Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
It have to convert to C99/C11 before PellesC can compile it :(

This gives lots of errors with gcc:
gcc.exe  -std=c11

EDIT:some fixes for PellesC with option -Zx
Code: [Select]
#ifdef __POCC__
#define typeof __typeof__
ptr_list create_list_size(size_t item_size);
//#define create_list(type)({create_list_size(sizeof(type));})
#define create_list(type) create_list_size(sizeof(type))

void list_add_ptr(ptr_list this_list, void* value);
void list_add_ptr_at(ptr_list this_list, void* value, int index);
#define list_add(list, value) {typeof(value) VAL = value; list_add_ptr(list, &VAL);}

void list_set_ptr(ptr_list this_list, int index, void* value);
#undef list_set
//#define list_set(list, index, value) ({typeof(value) VAL = value; list_set_ptr(list, index, &VAL);})
#define list_set(list, index, value) {typeof(value) _VAL; _VAL = value; list_set_ptr(list, index, &_VAL);}
#endif
and for list.h
Code: [Select]
//typedef struct list_options list_options, *ptr_list_options;
typedef struct _list_options
{
...
} list_options, *ptr_list_options;
...
//typedef struct _list _list, *ptr_list;
typedef struct _list
...
} _list, *ptr_list;

and for list.c
Code: [Select]
...
void* _list_index_ptr(ptr_list this_list, int index)
{
//    return ((void**)(this_list->_heap_ptr + (this_list->_item_size * index)));
    return ((void**)((unsigned char*)this_list->_heap_ptr + (this_list->_item_size * index)));
}
...
Can't fix this:
Code: [Select]
#define list_last_index_of(list, value) ({typeof(value) VAL = value; int index; index = list_last_index_of_ptr(list, &VAL); index;})
« Last Edit: May 03, 2018, 06:41:39 PM by TimoVJL »
May the source be with you