Erreur à la compilation

Résolu
cs_norton Messages postés 215 Date d'inscription mardi 21 janvier 2003 Statut Membre Dernière intervention 21 août 2011 - 25 nov. 2004 à 19:07
cs_norton Messages postés 215 Date d'inscription mardi 21 janvier 2003 Statut Membre Dernière intervention 21 août 2011 - 25 nov. 2004 à 22:50
bonsoir, si je fait #include "entree.h" dans le main.cpp quand je lance la compilation j'ai ces erreurs:

--------------------Configuration: Jack - Win32 Debug--------------------
Compiling...
Dll_main.cpp
c:\jackland\jackdll\main.h(28) : error C2011: 'Sprite' : 'struct' type redefinition
c:\jackland\jackdll\main.h(38) : error C2011: 'Objet' : 'struct' type redefinition
c:\jackland\jackdll\main.h(47) : error C2011: 'level_jack' : 'struct' type redefinition
c:\jackland\jackdll\main.h(64) : error C2084: function 'int __cdecl draw_player(int,int)' already has a body
c:\jackland\jackdll\main.h(77) : error C2084: function 'int __cdecl draw_object(int,int,int)' already has a body
Error executing cl.exe.

Jack.dll - 5 error(s), 0 warning(s)

pourquoi le compilateur me sort ces erreurs et comment faire pour que ca fonctionne quand j'inclus mon fichier entree.h ??

Merci et bonne soirée
++ Norton

3 réponses

cs_djl Messages postés 3011 Date d'inscription jeudi 26 septembre 2002 Statut Membre Dernière intervention 27 novembre 2004 7
25 nov. 2004 à 19:30
ton header est protègé contre les inclusions multiples ?
3
simtiers Messages postés 207 Date d'inscription jeudi 3 avril 2003 Statut Membre Dernière intervention 2 novembre 2006
25 nov. 2004 à 19:49
pour protéger contre les inclusions multiples :

-au début du fichier entree.h :
#ifndef ENTREE_H__INCLUDED
#define ENTREE_H__INCLUDED

-à la fin du fichier
#endif

Comme ça, le compilateur ne lira qu'une seule fois le fichier.
3
cs_norton Messages postés 215 Date d'inscription mardi 21 janvier 2003 Statut Membre Dernière intervention 21 août 2011
25 nov. 2004 à 22:50
Super ca fonctionne !!

Merci et bonne soirée
0
Rejoignez-nous