IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 C Discussion :

Erreur de segmentation


Sujet :

C

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    252
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 252
    Points : 192
    Points
    192
    Par défaut Erreur de segmentation
    Bonjour à tous.
    J'ai une erreur de segmentation dans mon fichier que je fourni en piece jointe.
    J'ai creusé un petit peu, car je ne savais pas trop comment faire...
    Comme je suis sous linnux, j'utilise gdb.
    Il y a une erreur sur free(), avec un renvoit à une bibliothéque.
    J'ai également vérifier quelles fonctions été appelées.
    free() est appellé par demarre qui est appellé par la fonction main.
    L'erreur exacte est
    #0 0xb7e997bc in free () from /lib/tls/i686/cmov/libc.so.6
    #1 0x08049b26 in demarre () at othello.c:142
    #2 0x080496b0 in main () at othello.c:19
    Est ce que quelqu'un pourrait m'aider s'il vous plait ?
    Merci d'avance

  2. #2
    Expert éminent sénior
    Avatar de diogene
    Homme Profil pro
    Enseignant Chercheur
    Inscrit en
    Juin 2005
    Messages
    5 761
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Enseignement

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 761
    Points : 13 926
    Points
    13 926
    Par défaut
    Comment te répondre ?
    - On ne connait pas les types particuliers de ton problème (JOUEUR ?)
    - On ne connait pas les variables J2, J4 , othelier, chemin,....ni la déclaration de leur type
    - On voit des free, mais on ne sait pas où sont les malloc correspondant.
    Publication : Concepts en C

    Mon avatar : Glenn Gould

    --------------------------------------------------------------------------
    Une réponse vous a été utile ? Remerciez son auteur en cliquant le pouce vert !

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    252
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 252
    Points : 192
    Points
    192
    Par défaut
    Il s'agit du jeu othello, J2 et J4 sont des joueurs, othello est une fonction qui attribution une valeur à des cases (X, O ou ., . represente le vide pour une case.
    Je fourni en piece jointe le fichier sauvegarde ou toutes les fonctions pour sauvegarder sont présentent
    Pour info, toutes les primitives sont définis dans des hearder à part, le projet compile sans souci, mais quand je sauvegarde (à la fin d'un jeu) j'ai 2 chances sur trois pour me faire insulter par mon ordinateur

  4. #4
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    poste tout le code sinon comment veux tu que l'on compile!!
    "The quieter you become, the more you are able to hear"
    "Plus vous êtes silencieux, plus vous êtes capable d'entendre"

  5. #5
    Membre habitué
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    252
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 252
    Points : 192
    Points
    192
    Par défaut
    Voici l'intégralité de la source
    Merci pour votre aide
    Pour compiler, vous fait un make, le makefile contenant l'option -g, pour débuguer, j'ai utilisé gdb

    Edit: erreur lors de l'envoi du zip

  6. #6
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    In file included from evaluation.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 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:151: attention : function declaration isn"t a prototype
    othello.c: In function «demarre":
    othello.c:73: attention : «score" may be used uninitialized in this function
    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
    representation.c: In function «initialiseGrilleDepart":
    representation.c:27: erreur: expected «)" before «othelier"
    representation.c:237: erreur: expected declaration or statement at end of input
    representation.c:237: erreur: expected declaration or statement at end of input
    representation.c:237: erreur: expected declaration or statement at end of input
    si tu indentais correctement ton code tu aurais remarqué :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    #include<stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include "sauvegarde.h"
    #include "evaluation.h"
    #include "alpha.h"
    #include "regles.h"
    #include "representation.h"
    #include "optimisation.h"
    #include "othello.h"
     
    int NBCOUPS_JOUES;
    char CAMP_QUI_A_JOUE;           /*met en evidence les cases jouables */
    void initialiseGrilleDepart (int taille)
    {
       int i, j;
       taille = 8;
       Dimmax = taille;
     
       othelier = (char *) malloc ((Dimmax * Dimmax * sizeof (char)));
     
       for (i = 0; i < taille; i++)
       {
          for (j = 0; j < taille; j++)
          {
             if ((i == 3) && (j == 3)
                 othelier[Dimmax * i + j] = 'O';
                 else
                 if ((i == 4) && (j == 4)
                     othelier[Dimmax * i + j] = 'O';
     
                     else
                     if ((i == 3) && (j == 4)
                         othelier[Dimmax * i + j] = 'X';
     
                         else
                         if ((i == 4) && (j == 3)
                             othelier[Dimmax * i + j] = 'X';
                             else
                             othelier[Dimmax * i + j] = '.';
     
                             }
                             }
                             }
     
                             void afficheothellier (char *Grille)
                             {
     
                             int Ligne, k;
                             char Colone;
                             char Camp = adverse (CAMP_QUI_A_JOUE);
                 printf ("\n\t\tOTHELIER  %d X %d \n\n\n\t   ", Dimmax, Dimmax);
                             for (Colone = 'a'; Colone < Dimmax + 'a'; Colone++)
                             printf (" %c  ", Colone);
                             printf ("\n\t  +");
                             for (Ligne = 1; Ligne <= Dimmax; Ligne++)
                             {
                             for (k = 1; k <= Dimmax; k++)
                             printf ("---+");
                             printf ("\n\t%d ", Ligne);
                             for (Colone = 'a'; Colone < Dimmax + 'a'; Colone++)
                             {
                             if ((coupValide (Grille, Camp, Ligne, Colone)) == 1)
                             printf ("| - ");  /*mettre la case en evidance */
                             else
                        if ((Grille[Dimmax * (Ligne - 1) + Colone - 97]) == '.')
                             printf ("|   ");  /*afficher le vide */
                             else
                   printf ("| %c ", Grille[Dimmax * (Ligne - 1) + Colone - 97]);
                             }
                             printf ("| %d\n\t  +", Ligne);
                             }
                             for (k = 1; k <= Dimmax; k++)
                             printf ("---+");
                             printf ("\n\t   ");
                             for (Colone = 'a'; Colone < Dimmax + 'a'; Colone++)
                             printf (" %c  ", Colone);
                             printf ("\n");
     
                             }
     
                   void newposition (int *ptrNumligne, char *ptrNomcol, int dir)
     
                             {
       /* droite */
                             if (dir == 1)
                             (*ptrNomcol)++;
                             else
       /* Diagonale bas - droite */
                             if (dir == 2)
                             {
                             (*ptrNumligne)++;
                             (*ptrNomcol)++;
                             }
                             else
       /*bas */
                             if (dir == 3)
                             (*ptrNumligne)++;
                             else
       /* Diagonale bas - gauche */
                             if (dir == 4)
                             {
                             (*ptrNumligne)++;
                             (*ptrNomcol)--;
                             }
     
                             else
       /*  gauche */
                             if (dir == 5)
                             {
                             (*ptrNomcol)--;
                             }
     
                             else
       /* Diagonale haut - gauche */
                             if (dir == 6)
                             {
                             (*ptrNumligne)--;
                             (*ptrNomcol)--;
                             }
     
                             else
       /* Haut */
                             if (dir == 7)
                             {
                             (*ptrNumligne)--;
                             }
     
                             else
       /* Diagonale Haut  - droite */
                             if (dir == 8)
                             {
                             (*ptrNumligne)--;
                             (*ptrNomcol)++;
                             }
                             }
     
                             int retournePionsDansDirection (int Dir, char **Grille, int Numligne, char Nomcol, char camp)
     
                             {
                             int compteur = 0;
                             char contenu;
     
                             while ((Numligne >= 1) && (Numligne <= Dimmax) && (Nomcol >= 'a') && ((Nomcol - 'a') < Dimmax))
                             {
                             newposition (&Numligne, &Nomcol, Dir);
                       contenu = donnecontenudecase (*Grille, Numligne, Nomcol);
     
                             if ((contenu != camp) && (contenu != '.'))
                             {
                   (*Grille)[(Dimmax * (Numligne - 1)) + (Nomcol - 'a')] = camp;
                             compteur++;
                             }
                             else
                             break;
                             }
                             return compteur;
     
                             }
     
         int retournePions (char **Grille, int Numligne, char Nomcol, char camp)
     
                             {
                             int compteur = 0;
                             int dir;
                          if (coupValide (*Grille, camp, Numligne, Nomcol) == 1)
                             {
                             for (dir = 1; dir <= 8; dir++)
                             {
                             if (faitpriseDansDirection (dir, camp, *Grille, Numligne, Nomcol) == 1)
                             compteur += retournePionsDansDirection (dir, Grille, Numligne, Nomcol, camp);
                             }
                             }
                             return compteur;
                             }
     
             void JoueLeCoup (char **Grille, int Numlig, char Nomcol, char Camp)
                             {
                             retournePions (Grille, Numlig, Nomcol, Camp);
               (*Grille)[(Dimmax * (Numlig - 1)) + (int) (Nomcol - 'a')] = Camp;
                             }
     
                         void SaisiUnCoup (char Camp, int *Numlig, char *Nomcol)
                             {
                             do
                             {
                             printf ("ENTREZ LA CASE  A JOUER:\t");
                             scanf ("%c %d", Nomcol, Numlig);
                             getchar ();
                             if (*Nomcol != 'u')
                             {
                         if (coupValide (othelier, Camp, *Numlig, *Nomcol) == 0)
                             {
                     printf ("\n SAISIE  INVALIDE (%c,%d)\n", *Nomcol, *Numlig);
                             afficheothellier (othelier);
                             }
                             }
                             else
                             {
                             if (NBCOUPS_JOUES >= 6)
                             {
                           printf ("\n ANNULLATION DU DERNIER COUP EN COURS\n");
                             break;
                             }
                             else
                             {
                          printf ("\n IMPOSSIBLE DE REVENIR PLUS EN ARRIERE\n");
                             afficheothellier (othelier);
                             }
                             }
                             }
                     while (coupValide (othelier, Camp, *Numlig, *Nomcol) == 0);
                             }
     
                          void recopieGrille (char *Grilledeteste, char *Grille)
                             {
                             int i;
                             char j;
                             for (i = 1; i <= Dimmax; i++)
                             {
                             for (j = 'a'; j < Dimmax + 'a'; j++)
                             {
                             Grilledeteste[(Dimmax * (i - 1)) + (int) (j - 'a')] = donnecontenudecase (Grille, i, j);
                             }
                             }
                             }
     
                             void affichecoup (char colonne, int ligne)
                             {
                        printf ("\n\t  coup joue:  (%c,%d) \n", colonne, ligne);
                             }
    "The quieter you become, the more you are able to hear"
    "Plus vous êtes silencieux, plus vous êtes capable d'entendre"

  7. #7
    Membre habitué
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    252
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 252
    Points : 192
    Points
    192
    Par défaut
    Ok ,e "bug" des parenthèses est résolues, mais j'ai toujours ce souci
    Je suppose que mon erreur vient des protypes des fonctions qui ne sont pas correctes, alors je pose la question, comment faire pour que celui ci le soit ?
    D'ailleurs, j'en profite pour demander à nicolas quel outil as tu utilisé pour avoir toutes ces infos ?
    Merci

  8. #8
    Membre habitué
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    252
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 252
    Points : 192
    Points
    192
    Par défaut
    [QUOTE=nicolas.sitbon;3177399]
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    othello.c: In function «demarre":
    othello.c:73: attention : «score" may be used uninitialized in this function
    In file included from representation.c:4:
    Le problème vient de la je suppose non ???
    Je me pose toujours la même question comment as tu fais pour avoir ces infos ???
    Merci

  9. #9
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    -Pour le bug des parenthèses, j'attends que tu postes la correction.
    -Pour les prototypes, il suffit de rajouter void :
    =>
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    void sauvegarder (void);
    -pour le réglage du compilateur : http://emmanuel-delahaye.developpez....tm#cfg_compilo
    "The quieter you become, the more you are able to hear"
    "Plus vous êtes silencieux, plus vous êtes capable d'entendre"

  10. #10
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    void demarre ()
    {
       JOUEUR gagnant;
       int score, mode = modejeu ();
       sauvegarder ();
       initialiseGrilleDepart (5);
    
       if (mode == 1)
       {
          printf ("\nEntrez le nom du joueur qui debute  la partie (PIONS 'X') :\t ");
          scanf ("%s", j4.nom);
          getchar ();
          printf ("\nEntrez le nom du second joueur ( PIONS 'O') :\t ");
          scanf ("%s", j2.nom);
          getchar ();
          j4.camp = 'X';
          j2.camp = 'O';
          tabindic[0] = j4;
          tabindic[1] = j2;
          Moteur1 (othelier, 'X');
       }
       else if (mode == 2)
       {
          int niveau = niveaudujeu ();
          Moteur2 (othelier, 'X', niveau);
       }
       else
       {
          int niveau = niveaudujeu ();
          Moteur3 (othelier, 'X', niveau);
          printf ("\n\n\t La partie est terminée \n\n");
          score = Score (othelier);
       }
       if (score == 0)
          printf ("\nEgalité \n");
    
       else
       {
          if (mode == 1)
          {
             if (score < 0)
                gagnant = j2;
             else
                gagnant = j4;
             printf ("\n%s Gagne la partie avc un score de : %d \n", gagnant.nom, score);
          }
          else
          {
             if (mode == 2)
             {
                if (humaindebute == 'o')
                {
                   if (score < 0)
                   {
                      score = score * -1;
                      printf ("\nL'ordinateur gagne la partie avec un score de : %d \n", score);
                   }
                   else
                   {
                      score = score * -1;
                      printf ("\nVous gagnez la partie avec un score de : %d \n", score);
                   }
                }
                else
                {
                   if (score > 0)
                      printf ("\nL'ordinateur gagne la partie avec un score de : %d \n", score);
                   else
                      printf ("\nVous gagnez la partie avec un score de : %d \n", score);
                }
             }
             else
                printf ("\nLe score est  : %d \n", score);
          }
       }
       if (sauver == 'o')
       {
          SauvegardePartie (fichier, Dimmax);
          free (monfic);
          free (chemin);
       }
       free (othelier);
    
    }
    J'ai mis en gras le problème : tu déclares score, le problème c'est que tu l'initialise dans un if/else mais seulement dans le else. Donc si tu passes dans le if, tu ne l'initialises pas, du coup quand tu testes après sa valeur ça pose problème.
    "The quieter you become, the more you are able to hear"
    "Plus vous êtes silencieux, plus vous êtes capable d'entendre"

  11. #11
    Membre habitué
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    252
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 252
    Points : 192
    Points
    192
    Par défaut
    Merci beaucoup
    J'ai des progrès à faire encore je crois

  12. #12
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    Une fois le problème des parenthèses et des prototypes réglé, il reste :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    alpha.c: In function «CompteCasesVides":
    alpha.c:32: attention : unused parameter «Grille"
    regles.c: In function «faitpriseDansDirection":
    regles.c:16: attention : «contenu" may be used uninitialized in this function
    othello.c: In function «demarre":
    othello.c:72: attention : «score" may be used uninitialized in this function
    sauvegarde.c: In function «rejouePartie":
    sauvegarde.c:176: attention : declaration of «moncoup" shadows a global declaration
    optimisation.h:24: attention : déclaration est masquée ici
    sauvegarde.c:173: attention : unused parameter «Tailleothelier"
    optimisation.c: In function «Moteur2":
    optimisation.c:252: erreur: invalid application of «sizeof" to incomplete type «struct timezone" 
    optimisation.c:313: attention : comparer des nombres flottants à l'aide de == ou != n'est pas sûr
    optimisation.c: In function «Moteur3":
    optimisation.c:410: erreur: invalid application of «sizeof" to incomplete type «struct timezone" 
    optimisation.c:448: attention : comparer des nombres flottants à l'aide de == ou != n'est pas sûr
    "The quieter you become, the more you are able to hear"
    "Plus vous êtes silencieux, plus vous êtes capable d'entendre"

  13. #13
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    /* Structure crudely representing a timezone.
       This is obsolete and should never be used.  */
    struct timezone
      {
        int tz_minuteswest;		/* Minutes west of GMT.  */
        int tz_dsttime;		/* Nonzero if DST is ever in effect.  */
      };
    "The quieter you become, the more you are able to hear"
    "Plus vous êtes silencieux, plus vous êtes capable d'entendre"

  14. #14
    Membre habitué
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    252
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 252
    Points : 192
    Points
    192
    Par défaut
    J'ai recompilé et bien sur j'ai cru que le souci avait disparu mais non, cela aurait été trop simple
    Je ne comprends pas bien
    optimisation.c:252: erreur: invalid application of «sizeof" to incomplete type «struct timezone"
    Il ne faut pas faire un sizeof pour un timezone ?
    Que me conseilles tu ?

  15. #15
    Membre habitué
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    252
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 252
    Points : 192
    Points
    192
    Par défaut
    Je savais que c'était une fonction un peu has been, mais je ne peux pas du tout m'en servir ?

  16. #16
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    Entre
    L'utilisation de la structure timezone est obsolète, le champ tz_dsttime n'a jamais été utilisé sous Linux, il n'a jamais été géré, et ne le sera jamais par la libc ou glibc. Toute occurrence de ce champ dans les sources du noyau (sauf pour les déclarations) est un bug. Ainsi le paragraphe suivant n'a qu'un intérêt historique.
    et
    This is obsolete and should never be used.
    pour moi c'est clair, il ne faut pas utiliser timezone.
    "The quieter you become, the more you are able to hear"
    "Plus vous êtes silencieux, plus vous êtes capable d'entendre"

  17. #17
    Membre habitué
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    252
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 252
    Points : 192
    Points
    192
    Par défaut
    Penses tu que mon souci vient de la.
    Je tiens à préciser que jusqu'à présent, j'ai testé mon programme uniquement avec le mode 3 (machine vs machine)
    C'est au moment où j'enregistre mon fichier que cela plante.
    Le jeu tourne très bien sinon, l'ordinateur est plus fort que moi
    Je vais esayer une autre fonction
    Merci

  18. #18
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    Attention, les autres erreurs signalées dernièrement ne sont pas à prendre à la légères.
    "The quieter you become, the more you are able to hear"
    "Plus vous êtes silencieux, plus vous êtes capable d'entendre"

  19. #19
    Membre habitué
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    252
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 252
    Points : 192
    Points
    192
    Par défaut
    J'ai enlevé à titre de test la fonction gettimeofday.
    J'ai remplacé par une simple boucle afin de tester.
    Je n'ai donc plus les erreurs de sizeof, mais le programme plante toujours.
    A moins que tu voulais m'expliquer autre choses ?

  20. #20
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    Citation Envoyé par nicolas.sitbon Voir le message
    Une fois le problème des parenthèses et des prototypes réglé, il reste :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    alpha.c: In function «CompteCasesVides":
    alpha.c:32: attention : unused parameter «Grille"
    regles.c: In function «faitpriseDansDirection":
    regles.c:16: attention : «contenu" may be used uninitialized in this function
    othello.c: In function «demarre":
    othello.c:72: attention : «score" may be used uninitialized in this function
    sauvegarde.c: In function «rejouePartie":
    sauvegarde.c:176: attention : declaration of «moncoup" shadows a global declaration
    optimisation.h:24: attention : déclaration est masquée ici
    sauvegarde.c:173: attention : unused parameter «Tailleothelier"
    optimisation.c: In function «Moteur2":
    optimisation.c:252: erreur: invalid application of «sizeof" to incomplete type «struct timezone" 
    optimisation.c:313: attention : comparer des nombres flottants à l'aide de == ou != n'est pas sûr
    optimisation.c: In function «Moteur3":
    optimisation.c:410: erreur: invalid application of «sizeof" to incomplete type «struct timezone" 
    optimisation.c:448: attention : comparer des nombres flottants à l'aide de == ou != n'est pas sûr
    "The quieter you become, the more you are able to hear"
    "Plus vous êtes silencieux, plus vous êtes capable d'entendre"

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 3 123 DernièreDernière

Discussions similaires

  1. Erreurs de segmentation !
    Par anti-conformiste dans le forum Applications et environnements graphiques
    Réponses: 16
    Dernier message: 18/10/2005, 11h11
  2. Erreur de segmentation
    Par Trunks dans le forum C
    Réponses: 3
    Dernier message: 06/10/2005, 18h28
  3. Erreur de segmentation (Inconnue)
    Par Dark-Meteor dans le forum C
    Réponses: 5
    Dernier message: 08/09/2005, 13h42
  4. [Dev-C++] Erreur de segmentation...
    Par sas dans le forum Dev-C++
    Réponses: 11
    Dernier message: 26/03/2005, 14h25
  5. erreur de segmentation
    Par transistor49 dans le forum C++
    Réponses: 10
    Dernier message: 15/03/2005, 11h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo