| Computers Forum Index » Computer Compilers - LCC » newbie question: how to compile this program ?... |
|
Page 1 of 1 |
|
| Author |
Message |
| neoe77... |
Posted: Thu Jul 16, 2009 3:27 am |
|
|
|
Guest
|
anyone could please help me out of this:
===================my test c program====================
t1.c
#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. |
|
|
| Back to top |
|
|
|
| Friedrich Dominicus... |
Posted: Thu Jul 16, 2009 5:15 am |
|
|
|
Guest
|
neoe77 <neoedmund at (no spam) gmail.com> writes:
Quote: anyone could please help me out of this:
===================my test c program====================
t1.c
#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);
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. |
|
|
| Back to top |
|
|
|
|