Conflicting type plusieurs import
Bonjour, j'ai une erreur en important mon fichier .h dans deux fichiers différents :
TypeFourmi.h :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
typedef struct{
short pvMax;
short pa;
short speed;
short id;
}TypeFourmi;
TypeFourmi* createTypeFourmi(short pvMax,short pa,short speed);
void saveTypeFourmis(TypeFourmi* f);
TypeFourmi** loadTypeFourmis();
short getTypeLastId();
short getNbTypeFourmis(); |
mon code c equivalent ou j'importe mon h :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#ifndef _typef
#define _typef
#include "TypeFourmi.h"
#endif
#include <fcntl.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <dirent.h>
short id;
short nbTypeFourmis;
TypeFourmi* createTypeFourmi(short pvMax,short pa,short speed)
{
TypeFourmi* type = malloc(sizeof(TypeFourmi));
///
return type;
}
short getTypeLastId()
{
return id;
}
void saveTypeFourmis(TypeFourmi* f)
{
int fd;
/////
close(fd);
}
short getNbTypeFourmis()
{
return nbTypeFourmis;
}
TypeFourmi** loadTypeFourmis()
{
////
closedir(d);
}
} |
Avec ces deux fichiers mon programme fonctionne seulement l'ajout du 3éme fichier pose un soucis :
Fourmiliere.h
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| #ifndef _typef
#define _typef
#include "TypeFourmi.h"
#endif
typedef struct {
TypeFourmi **typeFourmis;
float *probaSpawn;
short nbTypeFourmis;
}fourmiliere;
fourmiliere* creerFourmilier(short nbTypefourmis,TypeFourmi **typeFourmis);
float addTypeFourmis(fourmiliere* f ,short id,float percent);
float checkPercent(fourmiliere* f ); |
Si je ne renseigne pas en import mon fichier TypeFourmi.h, cela créer une erreur de structure inconnue. Sinon j'obtiens un jolie conflicting type
/home/c/Bureau/projet/Info/TypeFourmi.h|6|error: conflicting types for ‘TypeFourmi’|
/home/c/Bureau/projet/Info/TypeFourmi.h|6|note: previous declaration of ‘TypeFourmi’ was here|
/home/c/Bureau/projet/Info/TypeFourmi.h|9|error: conflicting types for ‘createTypeFourmi’|
/home/c/Bureau/projet/Info/TypeFourmi.h|6|note: previous declaration of ‘TypeFourmi’ was here|
/home/c/Bureau/projet/Info/TypeFourmi.h|10|error: conflicting types for ‘saveTypeFourmis’|
/home/c/Bureau/projet/Info/TypeFourmi.h|6|note: previous declaration of ‘TypeFourmi’ was here|
/home/c/Bureau/projet/Info/TypeFourmi.h|11|error: conflicting types for ‘loadTypeFourmis’|
Merci d'avance , ce n'est pas la premiere fois que j'ai ce genre de message, j'ai réussi la plus part du temps a résoudre les conflits sans jamais trop comprendre comment