allora, sia il tipo bool che vec_i che vec_p sono definiti in un altro .h e non causano problemi.
ora metto il codice del .c che causa problemi in compilazione.
Non fate caso alle righe di codice commentato che erano test vari.
gli errori di compliazione che escono sono 2: ovvero
8 C:\Documents and Settings\Pompolus\Desktop\LaboratorioProgrammazion e\prova2.0\modulo1.c In file included from modulo1.c
che me lo da alla riga 8 ovvero #include "clausole.h"
e
139 C:\Documents and Settings\Pompolus\Desktop\LaboratorioProgrammazion e\prova2.0\modulo1.c dereferencing pointer to incomplete type
che me lo da in ogni riga in cui provo a chiamare un oggetto ClauseLst.
ripeto che se dal modulo1.c non uso mai la struct ClauseLst, la compilazione non produce nessun errore.
ecco il codice:
codice:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <malloc.h>
#include "letterali.h"
#include "vettori.h"
#include "clausole.h" /////// <------- ERRORE
#include "solver.h"
#include "modulo1.h"
static char* readFile(FILE * in){
char * string;
int i=0;
while (!feof(in)) {
getc(in);
i++;
}
string = (char *) malloc(sizeof (char *) * i);
rewind(in);
i = 0;
while (!feof(in)) {
string[i] = getc(in);
i++;
}
return string;
}
static void crea_clausola(char **in, vec_i *v) {
int temp[100];
int i = 0, j, k, n, l, pos, ris = 0;
int ccc;
while((*in)[i] != '0'){
ris = 0;
pos = 0;
j = 0;
if ((*in)[i]=='-'){
pos = 1;
i++;
}
while ((*in)[i]>=48 && (*in)[i]<=57){
temp[j] = (*in)[i];
j++;
i++;
}
temp[j] = '\0';
k = 0;
while (temp[k] != '\0'){
n = (int ) temp[k] - 48;
for (l = 0; l < j-1-k; l++)
n = n * 10;
ris = ris + n;
k++;
}
if (pos == 1) ris = 0 - ris;
// printf("ris: %d ", ris);
veci_ins (v, ris);
if((*in)[i] != '\n')i++;
}
}
bool main_modulo1(FILE *in, solver *s){
int nrClauses = 0, nrLetterali = 0, i = 0, j = 0, k, n, l, t, h, prova, numLett, nc = 0, vc = 0, flag;
clause* cl;
//clause ** vcl;
CPtr cp, init; //// <------ ERRORE
clause * vcl;
vec_p * vp;
vec_i * vi;
// solver * solv;
char * stringa;
char * tttt;
char temp[100];
bool check;
// solv = solver_new();
stringa = readFile(in); //legge il file e lo copia nella stringa Stringa
while (stringa[i] != '\0'){
if (stringa[i] == 'c'){ //se la riga comincia per c
while (stringa[i] != '\n') //la salta completamente
i++;
}
i++;
if (stringa[i] == 'p'){ //controlla se è uguale a p
while ((int)stringa[i]<48 || (int)stringa[i]>57) //finchè non abbiamo numeri scorriamo la stringa
i++;
while ((int)stringa[i]>=48 && (int)stringa[i]<=57){ //qnd troviamo il primo numero lo memorizziamo in un array di appoggio
temp[j] = stringa[i];
j++;
i++;
}
temp[j] = '\0';
k = 0;
while (temp[k] != '\0'){ //trasformiamo il numero dell'array di appoggio temp in una variabile di tipo int
n = (int) temp[k] - 48;
for (l = 0; l < j-1-k; l++)
n = n * 10;
nrLetterali = nrLetterali + n;
k++;
}//abbaimo ottenuto il nr di letterali
while (stringa[i]<48 || stringa[i]>57) //scrorriamo avanti il puntatore finchè non troviamo numeri nuovamente
i++;
j = 0;
while (stringa[i]>=48 && stringa[i]<=57){ //se è un numero
temp[j] = stringa[i]; //lo memorizziamo in un array di appoggio temp
j++;
i++;
}
temp[j] = '\0'; //per poi trasformarlo in un vero intero
k = 0;
while (temp[k] != '\0'){
n = (int) temp[k] - 48;
for (l = 0; l < j-1-k; l++)
n = n * 10;
nrClauses = nrClauses + n;
k++;
}//abbiamo ottenuto il nr delle clausole
vi = (vec_i *) malloc(sizeof(vec_i)*nrClauses);
// vcl = (clause**)malloc(sizeof(clause*)*nrClauses);
/* for (h = 0; h < nrClauses; h++)
vcl[h] = (clause *)malloc(sizeof(clause));
*/
cp = (CPtr) malloc(sizeof(ClauseLst)); //// <------ ERRORE
cp->serial = 0;
cl = NULL;
cp->next = NULL;
init = cp;
// vcl = (clause**)malloc(sizeof(clause*)*nrClauses);
// vcl = (clause**)malloc(sizeof(clause));
s->nof_var=nrLetterali;
s->nof_clauses=nrClauses;
solver_init (s);
while (stringa[i] != '\n') //andiamo a capo
i++;
t = 0;
numLett = 0;
i++;
while (stringa[i+t] != '\0'){ //abbiamo considerato che ci sia un solo spazio tra i letterali e nessuno spazio prima
//dello 0
t = 0;
while (stringa[t+i] != '0'){
flag = 0;
if ((stringa[t+i]>=48 && stringa[t+i]<=57) || stringa[t+i]=='-') flag = 1;
while ((stringa[t+i]>=48 && stringa[t+i]<=57) || stringa[t+i]=='-')//se troviamo un numero o un -
t++;
if (flag == 1) numLett++; //incrementiamo i letterali
// if (stringa[t+i] != '\0' && stringa[t+i] != '\n' ) t++;
t++;
}
veci_new (vi, numLett);
tttt = &stringa[i];
printf("qui ci arriva 1?");
system("pause");
crea_clausola(&tttt, vi); ////
check = new_clause(False, numLett, 0.0, vi, vcl);
printf("qui non ci arriva 4?");
system("pause");
veci_delete (vi);
printf("qui non ci arriva 5?");
system("pause");
prova= solver_aggiungiclausola(s, vcl);
printf("qui non ci arriva 6?");
system("pause");
// nc++;
// vc++;
cp->next = (CPtr) malloc(sizeof(ClauseLst));
cp->next->serial = cp->serial + 1;
cp = cp->next;
cp->cl = NULL;
//free(vcl);
t++;
if (stringa[t+i] != '\0') t++;
i = i+t;
numLett = 0;
}
}
}
}
se trovate qualche tipo di dato che vi è sconosciuto, è definito in altri file .h