I am working on a program for school and although this is just a warning, I would like it to go away.
Basically, I have a function that returns a pointer to a struct called symrec. However, when I try to assign this return to another symrec pointer, I get the above error. Here is a sample:
struct symrec *s;
s=putsym(sym_name);
/*here is putsym function */
symrec * putsym(const char *sym_name, int sym_type){
symrec *ptr;
/*create new space from heap for new symrec*/
ptr = (symrec *) malloc (sizeof (symrec));
/*allocate space for the name of the symbol*/
ptr->name = (char *) malloc (strlen(sym_name) + 1);
/*assign the name of the symrec*/
strcpy (ptr->name,sym_name);
/*assign type to the symrec*/
ptr->type = sym_type;
/* Set value to 0 even if fctn. */
ptr->value.var = 0;
/*insert it into the beginning of the symbol table*/
ptr->next = (struct symrec *)sym_table;
/*assign the sym_table to point to the new head of the table*/
sym_table = ptr;
return ptr;
}
Any ideas how I can fix the error?
Thanks in advance.
Basically, I have a function that returns a pointer to a struct called symrec. However, when I try to assign this return to another symrec pointer, I get the above error. Here is a sample:
struct symrec *s;
s=putsym(sym_name);
/*here is putsym function */
symrec * putsym(const char *sym_name, int sym_type){
symrec *ptr;
/*create new space from heap for new symrec*/
ptr = (symrec *) malloc (sizeof (symrec));
/*allocate space for the name of the symbol*/
ptr->name = (char *) malloc (strlen(sym_name) + 1);
/*assign the name of the symrec*/
strcpy (ptr->name,sym_name);
/*assign type to the symrec*/
ptr->type = sym_type;
/* Set value to 0 even if fctn. */
ptr->value.var = 0;
/*insert it into the beginning of the symbol table*/
ptr->next = (struct symrec *)sym_table;
/*assign the sym_table to point to the new head of the table*/
sym_table = ptr;
return ptr;
}
Any ideas how I can fix the error?
Thanks in advance.