d'inclusion cyclique et makefile
Bonjour
J'ai un problème d'inclusion cyclique...
Je sais que le probléme à été traité plusieurs fois mais je n'ai pas réussi à mettre en
place la solution sauf si le problème vient d'ailleur
voici la situation : -> sinifiant 'fait référence'
liste -> widget
widget -> top
top -> liste
J'ai donc procédé comme ceci :
Faire une déclaration anticipé dans liste .
Dans liste.h
typedef struct widget ;
Dans liste.c
#include "liste.h"
#include "widget.h"
J'ai cette erreur à la compilation.
Citation:
Using Makefile from ~/Bureau/SDL_GTK
make: entrant dans le répertoire « /home/vincent/Bureau/SDL_GTK »
gcc -c top.c -Wall -Wextra
In file included from top.h:10,
from top.c:1:
liste.h:7: warning: useless storage class specifier in empty declaration
liste.h:11: error: expected specifier-qualifier-list before ‘Widget’
make: quittant le répertoire « /home/vincent/Bureau/SDL_GTK »
liste.h:24: error: expected declaration specifiers or ‘...’ before ‘Widget’
liste.h:25: error: expected specifier-qualifier-list before ‘Widget’
liste.h:31: error: expected declaration specifiers or ‘...’ before ‘Widget’
liste.h:33: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
In file included from top.c:1:
top.h:12: warning: empty declaration with storage class specifier does not redeclare tag
make: *** [top.o] Erreur 1
Voici le début des fichiers concernés :
liste.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
|
#ifndef liste_h
#define liste_h
#include <stdlib.h>
//#include "widget.h"
typedef struct Widget;
typedef struct Maillon
{
Widget * widget ;
struct Maillon * next ;
struct Maillon * prev ;
} Maillon ;
typedef struct Liste
{
// membre
Maillon * last ;
Maillon * first ;
int size ;
// méthode
void (*append) (struct Liste *, Widget * );
Widget * (*get) (struct Liste *, int );
int (*vide) (struct Liste * );
int (*get_size)(struct Liste * );
} Liste; |
liste.c
Code:
1 2 3
|
#include "liste.h"
#include "widget.h" |
widget.h
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#ifndef widget_h
#define widget_h
#include <SDL/SDL.h>
#include "top.h"
typedef struct Widget
{
SDL_Surface * _surface ;
Top * _master ;
int (*get_height) () ;
int (*get_width) () ;
} Widget ; |
widget.c
top.h
Code:
1 2 3 4 5 6 7 8 9 10 11
|
#ifndef top_h
#define top_h
#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
#include "liste.h" |
top.c
makefile
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
all :: test
liste.o : liste.c liste.h
gcc -c liste.c -Wall -Wextra
top.o : top.c top.h
gcc -c top.c -Wall -Wextra
widget.o : widget.c
gcc -c widget.c -Wall -Wextra
label.o : label.c label.h
gcc -c label.c -Wall -Wextra
test : test.c top.o label.o widget.o liste.o
gcc -o test test.c top.o label.o widget.o liste.o -lSDL -lSDL_ttf
clean ::
rm -rf *.o
mrproper :: clean
rm -rf test |
merci d'avance.