#include <containers.h>
#include <list.h>
typedef struct {
int v;
char s[10];
} MyStruct;
int main(void){
List list= newList(sizeof(MyStruct));
MyStruct data;
int nb = list->lpVtbl->Add(&list,&data);
nb = list->Add(&data);
return 0;
}
==================compiler output====================
C:\lcc\bin>lcc -o a.exe t1.c
Error t1.c: 11 left operand of -> has incompatible type 'struct
_List'
Error t1.c: 11 left operand of -> has incompatible type 'struct
_List'
Error t1.c: 11 found 'struct _List' expected a function
Warning t1.c: 11 missing prototype
Error t1.c: 11 operands of = have illegal types 'int' and 'void'
Error t1.c: 12 left operand of -> has incompatible type 'struct
_List'
Error t1.c: 12 found 'struct _List' expected a function
Warning t1.c: 12 missing prototype
Error t1.c: 12 operands of = have illegal types 'int' and 'void'
7 errors, 2 warnings
=================lcc-win32 stand libary help==================
Function: Add
Synopsis
#include <containers.h>
int (*Add)(List *L1,void *data);
Description
This function adds an element at the end of the given list.
Returns
The number of elements in the list
Example:
List list;
MyStruct data;
int nb = list->lpVtbl->Add(&list,&data);
This simpler syntax is also accepted:
int nb = list->Add(&data);
============
thanks in advance.
This prototyp seems to be wrong it
is List &L1
and list.h contains some other implementation of list (more
traditional C)
what you like to have is
#include <containers.h>
typedef struct {
int v;
char s[10];
} MyStruct;
int main(void){
List list= newList(sizeof(MyStruct));
MyStruct data;
int nb = list.lpVtbl->Add(list,&data);
nb = list.Add(&data);
return 0;
}
However two times &data is probably a very bad idea....
Regards
Friedrich
--
Please remove just-for-news- to reply via e-mail.
This is a catastrophic bug in the documentation.
List is an object, not a pointer! That is why the
"->" doesn't work.
Here is a version that compiles cleanly:
#include <containers.h>
typedef struct {
int v;
char s[10];
} MyStruct;
int main(void){
List list= newList(sizeof(MyStruct));
MyStruct data;
// Note the . instead of ->
int nb = list.lpVtbl->Add(list,&data);
nb = list.Add(&data);
return 0;
}
I have updated the documentation eliminating those errors
Sorry about this