Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1831 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  Probleme syntaxe thread librairie pthread

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Probleme syntaxe thread librairie pthread

n°1362415
turn3r
Un clavier azerty en vaut 2
Posté le 09-05-2006 à 14:40:22  profilanswer
 

Bonjour,
je n'arrive pas à compiler ce petit programme servant a illustrer mon problème :
 

Code :
  1. #include <iostream>
  2. #include <pthread.h>
  3. using namespace std;
  4. static pthread_mutex_t mutex;
  5. class Foo
  6. {
  7.     string f;
  8.     Foo();
  9.     ~Foo();
  10.     void* affiche(void *p_data);
  11. };
  12. Foo::Foo ()
  13. {
  14.     string tmp("Je suis Foo" );
  15.     f=tmp;
  16. }
  17. Foo::~Foo()
  18. { }
  19. void* Foo::affiche(void *p_data)
  20. {
  21.     cout << f << endl;
  22.     return NULL;
  23. }
  24. int main()
  25. {
  26.     pthread_mutex_init (&mutex, NULL);
  27.     pthread_t thrd1;
  28.     Foo f;
  29.     pthread_create(&thrd1,NULL,f.affiche,NULL);
  30.     pthread_join(thrd1, NULL);
  31.     cout << "Fin" << endl;
  32.     return 0;
  33. }


 
Ce programme ne fait pas grand chose, il sert juste d'illustration au problème que je rencontre.
 
Pourquoi le compilo me dit-il :  
fichier.cpp:40: error: argument of type `void*(Foo::)(void*)' does not match `void*(*)(void*)'
Et comment résoudre mon problème.
D'avance merci !
 
TuRn3r


Message édité par turn3r le 09-05-2006 à 15:29:16

---------------
Les ventes de véhicules neufs ont chuté de 7%, y'en a marre des pirates qui téléchargent illégalement des voitures sur internet !!
mood
Publicité
Posté le 09-05-2006 à 14:40:22  profilanswer
 

n°1362714
breizhbugs
Posté le 09-05-2006 à 18:53:59  profilanswer
 

Salut,
Tu lui passe une methode d'une classe alors qu'il attend une fonction!

n°1362731
Taz
bisounours-codeur
Posté le 09-05-2006 à 19:32:25  profilanswer
 

et c'est tout. Alors sois fais une recherche, soit utilise boost.


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  Probleme syntaxe thread librairie pthread

 

Sujets relatifs
Problème pour créer ma page web[Js]Problème d'externalisation d'évènement onclick
[JS] probleme pr instancier une objetprobleme : Select d'une requette MYSQL
Threads sur un serveur J2EE ? Thread en tant que Singleton?ORACLE 9i : problème ISO 2
Probleme avec les caractères accentués en ut-8(sql)problème d'affichage avec preg_match
Probleme affiche de mon site sous FireFoxproblème de bouton...
Plus de sujets relatifs à : Probleme syntaxe thread librairie pthread


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR