Reputation: 78
I have a warning but i can't understand why:
void stampaCon(){
pthread_mutex_lock(&mutexCon);
printf("lista dei connesi: \n");
int i;
for(i=0; i<=MAX_CONNECTIONS*8; i++){
if(arrayCon[i]!=NULL){
TipoListaReg *s = NULL;
s = arrayCon[i]; //gives me a warning
printf("utente %s\n", arrayCon[i]->utente);
while(s->next!=NULL){
printf("utente %s\n", s->next->utente);
s=s->next;
}
}
}
pthread_mutex_unlock(&mutexCon);
}
TipoListaReg structure is:
typedef struct NodoListaReg {
char utente[MAX_NAME_LENGTH+1];
int connesso;
ListaPendente *msgs;
struct NodoListaReg *next;
} TipoListaReg;
and arrayReg is a global variable defined as:
TipoListaReg *arrayReg[512];
and this is a struct ListaPendente:
typedef struct pendenti{
char msg[MAX_MSG_SIZE];
char mittente[MAX_NAME_LENGTH+1];
int type;
struct pendenti *next;
}ListaPendente;
the warning is:
warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
Upvotes: 0
Views: 199
Reputation: 50776
There is not really enough information in your question, but this compiles fine without warnings:
typedef struct ListaPendente // made up definition by me as you didn't provide
{ // the definition of ListaPendente
int dummy;
} ListaPendente ;
typedef struct NodoListaReg {
char utente[100]; // MAX_NAME_LENGTH replaced by 100 as it is not relevant
int connesso;
ListaPendente *msgs;
struct NodoListaReg *next;
} TipoListaReg;
TipoListaReg *arrayReg[512];
int main()
{
int i = 0;
TipoListaReg *s = arrayReg[i]; // no warning here
}
However the code won't do anything useful
Upvotes: 2