It's been a while since I programmed in C, and I'm confused as to why I get
the following error message (why aren't they both "pointer to struct
chromT{}"?:
"genet.c", line 192: warning: assignment type mismatch:
pointer to struct {double score, enum {worst(2), mid(1), best(0)}
cat, array[10] of pointer to struct geneT {..} genes, pointer to struct
chromT {..} next} "=" pointer to struct chromT {}
my code is as follows (I have noted the line with the problem):
// DATA STRUCTURES
typedef struct {
double score;
categ cat;
struct geneT *genes[GENES_PER_CHROM];
struct chromT *next;
} chromT;
typedef struct {
double x[PTS_PER_FEAT];
double id; // something to keep track of each feature.
} geneT;
// FUNCTION PROTOTYPES
static void *LLGo (chromT *start, int n);
/* LLGo
*
* This function returns the address of the "n-th" element
* in the linked list.
*/
static void *LLGo (chromT *start, int n) {
int i = 0;
chromT *cursor = start;
while((cursor->next != NULL) && (i < n)) {
cursor = cursor->next; // THIS IS THE LINE WITH THE PROBLEM
i++;
}
if(i < n) {
return NULL;
}
else {
return cursor;
}
}