Bonjour,

Quelqu'un saurait-il m'expliquer à quoi est du ce problème d'inclusions multiples?

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
 
------------------------------------------------------------------------makefile
  BIN = projet
  OBJECTS =  mainframe.o projet.o 
  CXX = g++
 
OPTION1 = `wx-config --libs`
OPTION2 = `wx-config --cxxflags`
 
  all: $(OBJECTS)
	$(CXX)   $(OBJECTS) $(OPTION1) -Wall -o $(BIN)
 
mainframe.o: mainframe.cpp mainframe.h
	$(CXX) $(OPTION2) -c mainframe.cpp
projet.o: projet.cpp projet.h
	$(CXX) $(OPTION2) -c projet.cpp
clean: 
	rm -f *.o *~ projet

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
 
-----------------------------------------------Fichier projet.h
#ifndef PROJET_H
#define PROJET_H
 
#include <wx/wx.h>
#include "mainframe.h"
 
class Projet:public wxApp{	
 private:
  MainFrame *frame;
 public:
  virtual bool OnInit();
};
 
DECLARE_APP(Projet)
 
#endif
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
-----------------------------------------------Fichier projet.cpp
#include "projet.h"
 
IMPLEMENT_APP(Projet)
 
bool Projet::OnInit(){
  frame = new MainFrame("name Program",wxPoint(50,50),wxSize(450,340));
  frame->Show(TRUE);
  SetTopWindow(frame);
  return TRUE;
}

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
 
-----------------------------------------------Fichier mainframe.h
#ifndef MAINFRAME_H
#define MAINFRAME_H
 
#include <wx/wx.h>
#include "messages.h"
 
 
class MainFrame : public wxFrame{
 public:
   MainFrame(const wxString&,const wxPoint&,const wxSize&);
};
 
#endif
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
-----------------------------------------------Fichier mainframe.cpp
#include "mainframe.h"
 
MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
  : wxFrame((wxFrame *)NULL, -1, title, pos, size){
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
----------------------------------------------Fichier messages.h
#ifndef MESSAGES_H
#define MESSAGES_H
 
int n;
 
#endif
Le compilateur renvoie cette erreur:
projet.o(.bss+0x4): définitions multiples de « n »
mainframe.o(.bss+0x0): défini pour la première fois ici

Merci
Sam