cs_hdaniel
Messages postés37Date d'inscriptionvendredi 9 juillet 2004StatutMembreDernière intervention18 octobre 2010
-
18 oct. 2010 à 16:25
cptpingu
Messages postés3837Date d'inscriptiondimanche 12 décembre 2004StatutModérateurDernière intervention28 mars 2023
-
18 oct. 2010 à 17:51
Bonjour,
un extrait du code :
- dans un .h :
typedef struct EVENT_STRUCT_TAG {
vrt_event_handler_t handler; //!< Function pointer to event handler.
void *attribute; //!< Pointer to the storage where the event's attributes can be found. NULL if none available.
} vrt_event_t;
- et dans un .c :
/* Extract next event and call the event handler if it is known to the system. */
vrt_event_t *this_event = &vrt_event_fifo[vrt_event_fifo_tail];
c'est sur la dernière expression "(this_event->handler)(this_event->attribute); " que je bloque
je suis pas habitué à cette écriture.
si qq pouvait m'éclairer ;)
cptpingu
Messages postés3837Date d'inscriptiondimanche 12 décembre 2004StatutModérateurDernière intervention28 mars 2023123 18 oct. 2010 à 17:14
C'est juste l'utilisation d'un pointeur sur fonction:
#include <stdio.h>
typedef void (*pfunc)(int);
void displayInt(int a)
{
printf("Int est: %i\n", a);
}
int main()
{
pfunc func = &displayInt;
func(120);
(func)(90); /* ou on peut parenthésé */
return 0;
}
________________________________________________________________________
Historique de mes créations, et quelques articles:
[ http://0217021.free.fr/portfoliohttp://0217021.free.fr/portfolio]
Merci d'utiliser Réponse acceptée si un post répond à votre question
cptpingu
Messages postés3837Date d'inscriptiondimanche 12 décembre 2004StatutModérateurDernière intervention28 mars 2023123 18 oct. 2010 à 17:51
Sûrement pour lever une ambiguïté, mais je n'ai pas d'exemples en tête qui pourraient en provoquer.
Dans l'exemple que tu as donné, on peut se passer de la parenthèse.
________________________________________________________________________
Historique de mes créations, et quelques articles:
[ http://0217021.free.fr/portfoliohttp://0217021.free.fr/portfolio]
Merci d'utiliser Réponse acceptée si un post répond à votre question