hello,
can someone help in removing these errors from my c code:
prog.h code:
Code:
typedef struct iosig
{
int signal_name;
int signal_sub;
}IoSignal;
typedef struct contsig
{
int diff; /* 1, 2, etc. 0 if no derivative */
int power; /* 2, 3, etc. 1 if no power */
IoSignal iosig;
struct contsig *next;
}ContSig;
typedef struct contterm
{
double coeff;
ContSig *csig, *csig_tail; /* could be NULL if just const coeff */
struct contterm *next;
}ContTerm;
typedef struct Conteqn
{
double coeff;
ContTerm *cterm, *cterm_tail; /* could be NULL if just const coeff */
struct conteqn *next;
}ContEqn;
extern ContEqn *new_conteqn(int i,ContTerm *cterm);
extern ContTerm *new_cterm( ContSig *csig);
extern ContSig * new_csig ( int i,IoSignal iosig,int j);
extern IoSignal iosign( int i,int j);
extern void append_conteqn( ContEqn *conteqn,ContTerm *cterm);
extern ContEqn* append_cterm( ContEqn *conteqn, int sig ,ContTerm *cterm);
extern void append_csig( ContTerm *cterm,ContSig *csig);
prog.c code starting from line 44
Code:
Conteqn *new_conteqn(int i,ContTerm *cterm)
{
struct Conteqn *e = malloc( sizeof( struct conteqn ));
if( e == NULL)
{
yyerror( "new_node: malloc failed");
exit(1);
}
e->coeff = i;
e->cterm = e->cterm_tail = cterm;
e->next = NULL;
return e;
}
void append_conteqn( Conteqn *conteqn,ContTerm *cterm)
{
conteqn->cterm_tail->next =cterm;
conteqn->cterm_tail=cterm;
}
ContTerm *new_cterm( ContSig *csig)
{
struct contterm *e = malloc( sizeof( struct ContTerm) );
if( e == NULL)
{
yyerror( "new_node: malloc failed");
exit(1);
}
e->csig = e->csig_tail = csig;
e->next = NULL;
return e;
}
void append_cterm( ContTerm *cterm, int sig, ContSig *csig)
{
cterm->csig_tail->next = csig;
cterm->csig_tail = csig;
cterm->coeff = sig;
}
ContSig * new_csig ( int i, IoSig iosig, int j)
{
struct contsig *e = malloc( sizeof( struct ContSig));
if( e == NULL)
{
yyerror( "new_node: malloc failed");
exit(1);
}
e->iosig = iosig;
e->diff=i;
e->power =j;
e->next = NULL;
return e;
}
void append_csig( ContSig *csig , IoSignal* iosig )
{
csig->iosig.next = iosig;
csig->iosig = iosig;
csig->diff = csig->diff;
csig->power = csig->power;
}
IoSignal iosign( int i,int j)
{
IoSignal x;
x.signal_name = i;
x.signal_sub = j;
return x;
}
errors:
jpj.c: At top level:
jpj.c:44: parse error before '*' token
jpj.c:45: warning: return type defaults to `int'
jpj.c:45: conflicting types for `new_conteqn'
jpj.h:52: previous declaration of `new_conteqn'
jpj.c: In function `new_conteqn':
jpj.c:46: sizeof applied to an incomplete type
jpj.c:55: warning: return from incompatible pointer type
jpj.c: At top level:
jpj.c:58: parse error before '*' token
jpj.c: In function `append_conteqn':
jpj.c:59: number of arguments doesn't match prototype
jpj.h:60: prototype declaration
jpj.c:60: `conteqn' undeclared (first use in this function)
jpj.c:60: `cterm' undeclared (first use in this function)
jpj.c: In function `new_cterm':
jpj.c:67: sizeof applied to an incomplete type
jpj.c: At top level:
jpj.c:80: conflicting types for `append_cterm'
jpj.h:62: previous declaration of `append_cterm'
jpj.c:86: parse error before "IoSig"
jpj.c: In function `new_csig':
jpj.c:87: number of arguments doesn't match prototype
jpj.h:56: prototype declaration
jpj.c:88: sizeof applied to an incomplete type
jpj.c:94: `iosig' undeclared (first use in this function)
jpj.c:95: `i' undeclared (first use in this function)
jpj.c:96: `j' undeclared (first use in this function)
jpj.c: At top level:
jpj.c:102: conflicting types for `append_csig'
jpj.h:64: previous declaration of `append_csig'
jpj.c: In function `append_csig':
jpj.c:103: structure has no member named `next'
jpj.c:104: incompatible types in assignment
regards,
cutelucks