Bonjour,
Voici le log complet de compilation chez moi :
"C:\Program Files\JetBrains\CLion 2018.1.6\bin\cmake\bin\cmake.exe" --build C:\Users\Greextpgr\CLionProjects\untitled\cmake-build-debug --target untitled -- -j 2
Scanning dependencies of target untitled
[ 50%] Building CXX object CMakeFiles/untitled.dir/main.cpp.obj
C:\Users\Greextpgr\CLionProjects\untitled\main.cpp:9:2: error: conflicting declaration 'typedef struct noeud noeud'
}noeud, *ptrNoeud;
^~~~~
C:\Users\Greextpgr\CLionProjects\untitled\main.cpp:7:9: note: previous declaration as 'struct noeud'
struct noeud *filsD, *filsG;
^~~~~
C:\Users\Greextpgr\CLionProjects\untitled\main.cpp: In function 'noeud* nouvNoeud(char)':
C:\Users\Greextpgr\CLionProjects\untitled\main.cpp:13:43: error: invalid application of 'sizeof' to incomplete type 'noeud'
newnoeud= (ptrNoeud) malloc (sizeof(noeud));
^
C:\Users\Greextpgr\CLionProjects\untitled\main.cpp: In function 'void parcoursprefixe(ptrNoeud)':
C:\Users\Greextpgr\CLionProjects\untitled\main.cpp:30:26: error: cannot convert 'noeud*' to 'ptrNoeud {aka noeud*}' for argument '1' to 'void parcoursprefixe(ptrNoeud)'
parcoursprefixe(n->filsG);
^
C:\Users\Greextpgr\CLionProjects\untitled\main.cpp:7:9: note: class type 'noeud' is incomplete
struct noeud *filsD, *filsG;
^~~~~
C:\Users\Greextpgr\CLionProjects\untitled\main.cpp:31:26: error: cannot convert 'noeud*' to 'ptrNoeud {aka noeud*}' for argument '1' to 'void parcoursprefixe(ptrNoeud)'
parcoursprefixe(n->filsD);
^
C:\Users\Greextpgr\CLionProjects\untitled\main.cpp:7:9: note: class type 'noeud' is incomplete
struct noeud *filsD, *filsG;
^~~~~
C:\Users\Greextpgr\CLionProjects\untitled\main.cpp: In function 'int main()':
C:\Users\Greextpgr\CLionProjects\untitled\main.cpp:42:30: error: cannot convert 'noeud*' to 'ptrNoeud {aka noeud*}' for argument '1' to 'void parcoursprefixe(ptrNoeud)'
parcoursprefixe(Arbre->filsG);
^
C:\Users\Greextpgr\CLionProjects\untitled\main.cpp:7:9: note: class type 'noeud' is incomplete
struct noeud *filsD, *filsG;
^~~~~
mingw32-make.exe[3]: *** [CMakeFiles\untitled.dir\build.make:62: CMakeFiles/untitled.dir/main.cpp.obj] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:67: CMakeFiles/untitled.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:79: CMakeFiles/untitled.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: untitled] Error 2
Je pense que cacher un pointeur avec typedef est une mauvaise idée partant d'un coup de flemme...
Je n'ai pas le temps de regarder ça depuis mais définir ta structure, puis faire un type sur cette struct, et enfin virer ptrNoeuf devrait rendre le code plus compréhensible.
EDIT : j'ai regardé rapidement, j'ai remplacé la déclaration des types par ça :
1 2 3 4 5 6 7 8
| struct struct_noeud {
char val;
int num;
struct struct_noeud *filsD, *filsG;
};
typedef struct struct_noeud noeud;
typedef noeud* ptrNoeud; |
Ca compile....mais ça crashe à l'exécution. Je te laisse chercher pourquoi, c'est assez facile.
Partager