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 :

probleme avec une variable globle externe...


Sujet :

C++

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Juin 2004
    Messages
    54
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Juin 2004
    Messages : 54
    Points : 76
    Points
    76
    Par défaut probleme avec une variable globle externe...
    Bonjour a tous,

    voilà, j'ai déclaré dans un fichier . h une variable externe, mais le problème est que quand j'essaie de compiler, j'btiens l'erreur suivante:
    error: expected initializer before '*' token"
    Voici mon fichier .h:
    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
     
    #ifndef __DTK_H__ 
    #define __DTK_H__
     
    #include "application.h" //dans lequel est defini dtk::application
     
    template <class T>
    bool dtk_init(int argc=0, char **argv=NULL);
    int dtk_run();
    bool dtk_exit();
    extern dtk::application* theApp;
     
    #include "dtk.cxx" //pour l'implémentation de mon template
     
    #endif
    Quelqu'un a déjà eu ça? (Tiens au fait j'utilise gcc4 comme compilo, si ça peux aider...)

  2. #2
    Rédacteur
    Avatar de Laurent Gomila
    Profil pro
    Développeur informatique
    Inscrit en
    Avril 2003
    Messages
    10 651
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Avril 2003
    Messages : 10 651
    Points : 15 920
    Points
    15 920
    Par défaut
    On peut voir application.h ?

  3. #3
    Membre expert
    Avatar de Pragmateek
    Homme Profil pro
    Formateur expert .Net/C#
    Inscrit en
    Mars 2006
    Messages
    2 635
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Formateur expert .Net/C#
    Secteur : Conseil

    Informations forums :
    Inscription : Mars 2006
    Messages : 2 635
    Points : 3 958
    Points
    3 958
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    extern dtk::application* theApp;
    Ca correspond a quoi?

    Un pointeur sur la methode Si oui :
    http://www.developpez.com/c/megacours/x2012.html

  4. #4
    Membre régulier
    Profil pro
    Inscrit en
    Juin 2004
    Messages
    54
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Juin 2004
    Messages : 54
    Points : 76
    Points
    76
    Par défaut
    Non, the app est juste un pointeur sur une variable de type applacation.
    Voici d'ailleurs le fichier.h:

    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
     
     
    #ifndef __DTK_APPLICATION_H__
    #define __DTK_APPLICATION_H__
     
    #include <++dfb.h>
    #include <idirectfbwindow.h>
    #include <directfb.h>
    #include <list>
    #include <map>
    #include "event.h"
    #include "window.h"
    #include "widget.h"
     
     
    namespace dtk
    {
     
    typedef std::map<DFBWindowID, window*> IdfbwMap;
     
    class application : protected eventReceiver
    {
    	friend class widget;
    	friend class button;
     
    	public:
    		application();
    		application(int argc, char **argv);
    		virtual ~application(); 
    		virtual int run();
    		virtual bool exit();
    		virtual IDirectFBWindow& createWindow (DFBWindowDescription &desc, bool isMain);
    		bool registerWindow(window &dtkwin, IDirectFBWindow& dfbwin);
    		bool unregisterWindow(IDirectFBWindow& dfbwin);
    	protected:
    		bool dispatch		(DFBEvent& event);
    		bool processNoneEvent	(DFBEvent		&event);
    		bool processUsrEvent	(DFBUserEvent	&event);
    		bool processWinEvent	(DFBWindowEvent	&event);
    		bool processInEvent		(DFBInputEvent	&event);
    		bool processUnivEvent	(DFBUniversalEvent &event);
    		IDirectFBWindow* getWindowById(const DFBWindowID& id);
     
    		IDirectFB idfb;
    		IDirectFBDisplayLayer ilayer;
    		IDirectFBSurface isurface;
    		IDirectFBEventBuffer ieventbuffer;
    		IDirectFBWindow *mainwin;
    		std::list<IDirectFBWindow*> Windows;
    		IdfbwMap dtkWindowMap;
    		bool done;
    };
     
    }
     
    #endif
    edit: tant que j'y suis voici le contenu du fichier cxx:

    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
     
    #ifdef __DTK_H__ 
     
     
    template <class T>
    bool dtk_init(int argc=0, char **argv=NULL)
    {
    	if (theApp) return false;
    	if (argc==0) 
    		theApp = new T();
    	else	
    		theApp = new T(argc, argv);
    	return(theApp == NULL);
    }
     
    bool dtk_exit()
    {
    	return theApp->exit();
    }
     
    int dtk_run()
    {
    	return theApp->run();
    }
     
    #endif

Discussions similaires

  1. probleme avec une variable
    Par chrisl0 dans le forum Langage
    Réponses: 4
    Dernier message: 09/02/2009, 10h54
  2. Probleme avec une variable
    Par julien2333 dans le forum Windows Forms
    Réponses: 3
    Dernier message: 03/07/2008, 14h57
  3. probleme avec une variable dans l'action
    Par you.baddi dans le forum Struts 1
    Réponses: 1
    Dernier message: 08/04/2008, 13h56
  4. Réponses: 2
    Dernier message: 28/06/2006, 15h56
  5. [POO] Problème avec une variable static
    Par grimsk dans le forum Langage
    Réponses: 5
    Dernier message: 23/05/2006, 01h58

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