J'ai l'impression que le souci vient du module de sauvegarde, chaque fois que je veux sauvegarder ça plante, je teste donc de ce coté pour le moment, en tout cas, merci pour ton aide.
Version imprimable
J'ai l'impression que le souci vient du module de sauvegarde, chaque fois que je veux sauvegarder ça plante, je teste donc de ce coté pour le moment, en tout cas, merci pour ton aide.
J'ai testé, et cela plante toujours, ce n'est donc pas la sauvegarde.
Que signifie declaration masqué ?
Je ne comprends pas bien:oops:
Cela veut dire que tu as une variable locale qui porte le même nom qu'une variable globale (pas bien les variables globales:() et donc empêche l'utilisation (la visibilité) de cette globale au sein de la fonction qui déclare la variable locale.
Désolé, j'ai beau cherché, je ne vois pas du tout
Ce que j'ai compris, pour revenir au problème de fond, c'est que je devrais utiliser un free, pour liberer quelque chose, mais je ne vois pas quoi ...
Mon programme inove:bug:
CODE/
ENTREZ LE NOM DU FICHIER DE SAUVEGARDE : 5461231
*** glibc detected *** /home/jerome/Bureau/OTHELLOCOMPLET/ok/othello: free(): invalid pointer: 0xb7fba883 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb7edbd65]
/lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb7edf800]
/home/jerome/Bureau/OTHELLOCOMPLET/ok/othello[0x8049b40]
/home/jerome/Bureau/OTHELLOCOMPLET/ok/othello[0x80496b0]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb7e88050]
/home/jerome/Bureau/OTHELLOCOMPLET/ok/othello[0x80486c1]
======= Memory map: ========
08048000-0804d000 r-xp 00000000 08:11 3965776 /home/jerome/Bureau/OTHELLOCOMPLET/ok/othello
0804d000-0804e000 rw-p 00005000 08:11 3965776 /home/jerome/Bureau/OTHELLOCOMPLET/ok/othello
0804e000-0990e000 rw-p 0804e000 00:00 0 [heap]
b7d00000-b7d21000 rw-p b7d00000 00:00 0
b7d21000-b7e00000 ---p b7d21000 00:00 0
b7e71000-b7e72000 rw-p b7e71000 00:00 0
b7e72000-b7fb6000 r-xp 00000000 08:11 3851532 /lib/tls/i686/cmov/libc-2.6.1.so
b7fb6000-b7fb7000 r--p 00143000 08:11 3851532 /lib/tls/i686/cmov/libc-2.6.1.so
b7fb7000-b7fb9000 rw-p 00144000 08:11 3851532 /lib/tls/i686/cmov/libc-2.6.1.so
b7fb9000-b7fbc000 rw-p b7fb9000 00:00 0
b7fc5000-b7fcf000 r-xp 00000000 08:11 3817539 /lib/libgcc_s.so.1
b7fcf000-b7fd0000 rw-p 0000a000 08:11 3817539 /lib/libgcc_s.so.1
b7fd0000-b7fd4000 rw-p b7fd0000 00:00 0
b7fd4000-b7fee000 r-xp 00000000 08:11 3817492 /lib/ld-2.6.1.so
b7fee000-b7ff0000 rw-p 00019000 08:11 3817492 /lib/ld-2.6.1.so
bfb48000-bfb5d000 rw-p bfb48000 00:00 0 [stack]
ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]
/CODE
Comment trouver ce pointeur fautif ?
Je te rappelle que pour le moment le code que j'ai ne compile pas, tu sautes des étapes, corriges tes erreurs!!! et postes les corrections!!!
Il ne compile pas du tout ???
C'est curieu car chez moi, en compilant avec l'option pedantic et Wall, ca compile sans aucun avertissement...
Je peux reposter le code, mais je n'ai pas corrigé mes fonctions car je n'ai pas augmenté le niveau d'avertissement
les erreurs empêchent la compilation :
Code:
1
2 optimisation.c:252: erreur: invalid application of «sizeof" to incomplete type «struct timezone" optimisation.c:410: erreur: invalid application of «sizeof" to incomplete type «struct timezone"
Il y a un souci là...
Je suis sous linux, la ubuntu 7.10, et je compile avec le makefile que j'ai fourni.
Bas c'est normal, si tu fais des modifs mais que tu ne me les donnes pas je ne peux pas les devinner!!! tout à l'heure tu as dis que tu avais fais quelque chose pour timezone mais quoi? postes ton code!!!!!!
Voici le code
J'avais supprimer la fonction gettimeofday, mais vu que ca ne faisait rien, je l'ai remise (je l'avais remplacé par une incrementation)
Dans ce code, il y a juste les parenthèses qui ont été corrigé, et ça compile chez moi:roll:
J'en reviens pas, j'ai passé la soirée à t'aider à corriger tes erreurs et tu n'as rien corrigé tans tes sources :
tu abuses!!!!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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97 sauvegarde.h:1: attention : function declaration isn"t a prototype sauvegarde.h:10: attention : function declaration isn"t a prototype sauvegarde.h:11: attention : function declaration isn"t a prototype In file included from evaluation.c:12: othello.h:1: attention : function declaration isn"t a prototype othello.h:2: attention : function declaration isn"t a prototype othello.h:3: attention : function declaration isn"t a prototype othello.h:4: attention : function declaration isn"t a prototype othello.h:5: attention : function declaration isn"t a prototype othello.h:6: attention : function declaration isn"t a prototype In file included from alpha.c:8: sauvegarde.h:1: attention : function declaration isn"t a prototype sauvegarde.h:10: attention : function declaration isn"t a prototype sauvegarde.h:11: attention : function declaration isn"t a prototype In file included from alpha.c:12: othello.h:1: attention : function declaration isn"t a prototype othello.h:2: attention : function declaration isn"t a prototype othello.h:3: attention : function declaration isn"t a prototype othello.h:4: attention : function declaration isn"t a prototype othello.h:5: attention : function declaration isn"t a prototype othello.h:6: attention : function declaration isn"t a prototype alpha.c:20: attention : no previous prototype for «max" alpha.c:28: attention : no previous prototype for «min" alpha.c: In function «CompteCasesVides": alpha.c:39: attention : unused parameter «Grille" In file included from regles.c:4: sauvegarde.h:1: attention : function declaration isn"t a prototype sauvegarde.h:10: attention : function declaration isn"t a prototype sauvegarde.h:11: attention : function declaration isn"t a prototype In file included from regles.c:10: othello.h:1: attention : function declaration isn"t a prototype othello.h:2: attention : function declaration isn"t a prototype othello.h:3: attention : function declaration isn"t a prototype othello.h:4: attention : function declaration isn"t a prototype othello.h:5: attention : function declaration isn"t a prototype othello.h:6: attention : function declaration isn"t a prototype regles.c: In function «faitpriseDansDirection": regles.c:15: attention : «contenu" may be used uninitialized in this function In file included from othello.c:8: sauvegarde.h:1: attention : function declaration isn"t a prototype sauvegarde.h:10: attention : function declaration isn"t a prototype sauvegarde.h:11: attention : function declaration isn"t a prototype In file included from othello.c:10: othello.h:1: attention : function declaration isn"t a prototype othello.h:2: attention : function declaration isn"t a prototype othello.h:3: attention : function declaration isn"t a prototype othello.h:4: attention : function declaration isn"t a prototype othello.h:5: attention : function declaration isn"t a prototype othello.h:6: attention : function declaration isn"t a prototype othello.c:14: attention : function declaration isn"t a prototype othello.c:30: attention : function declaration isn"t a prototype othello.c:44: attention : function declaration isn"t a prototype othello.c:57: attention : function declaration isn"t a prototype othello.c:71: attention : function declaration isn"t a prototype othello.c:154: attention : function declaration isn"t a prototype In file included from representation.c:4: sauvegarde.h:1: attention : function declaration isn"t a prototype sauvegarde.h:10: attention : function declaration isn"t a prototype sauvegarde.h:11: attention : function declaration isn"t a prototype In file included from representation.c:10: othello.h:1: attention : function declaration isn"t a prototype othello.h:2: attention : function declaration isn"t a prototype othello.h:3: attention : function declaration isn"t a prototype othello.h:4: attention : function declaration isn"t a prototype othello.h:5: attention : function declaration isn"t a prototype othello.h:6: attention : function declaration isn"t a prototype In file included from sauvegarde.c:8: sauvegarde.h:1: attention : function declaration isn"t a prototype sauvegarde.h:10: attention : function declaration isn"t a prototype sauvegarde.h:11: attention : function declaration isn"t a prototype sauvegarde.c:18: attention : function declaration isn"t a prototype sauvegarde.c:36: attention : function declaration isn"t a prototype sauvegarde.c:55: attention : function declaration isn"t a prototype sauvegarde.c: In function «rejouePartie": sauvegarde.c:192: attention : declaration of «moncoup" shadows a global declaration optimisation.h:20: attention : déclaration est masquée ici sauvegarde.c:189: attention : unused parameter «Tailleothelier" In file included from optimisation.c:8: sauvegarde.h:1: attention : function declaration isn"t a prototype sauvegarde.h:10: attention : function declaration isn"t a prototype sauvegarde.h:11: attention : function declaration isn"t a prototype In file included from optimisation.c:12: othello.h:1: attention : function declaration isn"t a prototype othello.h:2: attention : function declaration isn"t a prototype othello.h:3: attention : function declaration isn"t a prototype othello.h:4: attention : function declaration isn"t a prototype othello.h:5: attention : function declaration isn"t a prototype othello.h:6: attention : function declaration isn"t a prototype optimisation.c:136: attention : no previous prototype for «DonneParite" optimisation.c:170: attention : no previous prototype for «met_ajourcoeff" optimisation.c:213: attention : no previous prototype for «UNDO" optimisation.c: In function «Moteur2": optimisation.c:257: erreur: invalid application of «sizeof" to incomplete type «struct timezone" optimisation.c:320: attention : comparer des nombres flottants à l'aide de == ou != n'est pas sûr optimisation.c: In function «Moteur3": optimisation.c:419: erreur: invalid application of «sizeof" to incomplete type «struct timezone" optimisation.c:458: attention : comparer des nombres flottants à l'aide de == ou != n'est pas sûr
Je comprends tout à fait ton dernier post, cependant, je n'ai jamais utilisé autant d'option quand je compile
Pour ma part, j'ai toujours utilisé un simple Wall, étant donné le projet, j'utilise pedantic pour la norme iso et -g pour le debuggage, mais je n'ai jamais appris à utiliser toutes les options qu'il y a sur la page que tu m'as donné.
Ce qui explique que si on regarde mon makefile, il n'y a pas d'autres options.
Si tu compiles avec gcc dans un terminal, avec mon makefile, tu obtiendras le fichier othello.
Après les EDI, j'ai pas trop utilisé, bien ou mal, à voir.
Je pense que mon souci se situe au niveau du du sizeof, je creuse et je repost quand j'aurai une idée
J'ai modifier le fichier optimisation.
Concernant les proto des fonctions, je ne pense pas que le problème vienne de là...
J'ai désactivé la fonction moteur2, et j'ai bossé sur le moteur3.
J'ai enlevé le gettimeofday, pour utiliser la fonction time, mais à priori, j'ai du faire un truc qui ne fallait pas...
Ca compile (aux avertissement près), le programme ce lance mais:
Ca bloque, completement, j'ai laissé réfléchir l'ordinateur 1 minutes, rien (alors que c'est réglé sur 2 ou 8 secondes, je ne sais plus)
Enfin, cela fait beaucoup trop
Deuxiemement:
Si on regarde le nombre de pions, il y a 0 pions O et X
j'ai enfin modifé mon makefile pour le compiler comme Nicolas
Je crois que ce projet va me rendre chèvre :oops:
Bon, on va te le répéter une 10ieme fois : commences par corriger les warnings !
Des personnes qui maitrisent le C mieux que toi tente de t'aider, t'expliquer.
Elle te demandent de corriger ton code (warnings) afin de partir d'une base de travail "saine".
Si tu penses que les conseils donnés sont inutiles (comme corriger les warnings dont tu ne prends pas la peine de regarder), pourquoi continuer à poster ?
Si tu n'écoutes pas les conseils, les gens de t'aideront pas !
donc, merci de prendre en compte les conseils de nicolas.sitbon !
Pour info, voici le Makefile que j'utilise :
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 CC = @gcc CFLAGS = -std=c99 -fhosted -g3 -O -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Werror-implicit-function-declaration -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wlong-long -Wunreachable-code -Wextra othello: evaluation.o alpha.o regles.o othello.o representation.o sauvegarde.o optimisation.o $(CC) -o $@ $^ evaluation.o: evaluation.c evaluation.h $(CC) $(CFLAGS) -c $< alpha.o: alpha.c alpha.h $(CC) $(CFLAGS) -c $< regles.o:regles.c regles.h $(CC) $(CFLAGS) -c $< othello.o: othello.c othello.h $(CC) $(CFLAGS) -c $< representation.o: representation.c representation.h $(CC) $(CFLAGS) -c $< sauvegarde.o:sauvegarde.c sauvegarde.h $(CC) $(CFLAGS) -c $< optimisation.o:optimisation.c optimisation.h $(CC) $(CFLAGS) -c $< clean: rm -f *.o *.c~ *.h~ makefile~ othello *.dat~
J'ai modifier les prototypes des fonctions que le compilateur m'indiquait, mais maintenant, je n'arrive plus à compiler.
Je débute en programmation, alors s'il vous plait, soyez indulgent, merci.
Je le dis et je le répète, j'ai toujours appris à compiler avec un simple Wall.
Certe la technique n'est peut être pas bonne, mais je pense qu'il est normal que je sois un peu perdu dans tout cela :(
J'ai une autre question maintenant
Comment corriger l'erreur :
othello.c:14: erreur: number of arguments doesn"t match prototype et
othello.h:6: erreur: déclaration de prototype
Je mets en ligne mon nouveau source
Dans othello.h, enlève cette ligne :
et dans othello.c, modifieCode:extern int main (int);
enCode:int main ()
Code:int main (void)
Dans alpha.c, à quoi sert grille :
Code:
1
2
3
4
5 int CompteCasesVides(char* Grille)/* retourne le nombre de cases vides dans Grille*/ { return ((Dimmax * Dimmax) - NBCOUPS_JOUES); }
othello.c
othello.hCode:
1
2
3
4
5
6
7
8
9
10
11
12
13 char QueFaire () { char reputilisateur; do { printf ("\n Que voulez vous faire ? \n\n\t j = jouer\n\n\t q = quitter\n\n\t l = relire une partie sauvegardee\n"); scanf ("%c", &reputilisateur); getchar (); } while ((reputilisateur != 'j') && (reputilisateur != 'q') && (reputilisateur != 'l')); return reputilisateur; }
Code:extern char QueFaire (int);