[Enlightenment Foundation Libraries] - Utilisation d'Eina_list
Bonjour,
J'aimerais utiliser le systéme de list dnas mon programme, car je pense que ça peut faciliter la vie.
Pour ça j'utilise une EINA_LIST
Pour démarrer je me base sur cette exemple :
source : ici
qui présente ce code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| #include <Eina.h>
int main(int ac, char **av)
{
int i;
char *data;
Eina_List *list = NULL, *l = NULL;
if (ac <= 1)
return 0;
eina_init();
for (i=0; i<ac; i++)
list = eina_list_append(list, eina_stringshare_add(av[i]));
EINA_LIST_FOREACH(list, l, data)
printf("argument : %s\n", data);
return 0;
} |
Mais quand je compile ce programe j'ai pas mal de warnings :
Code:
1 2 3 4 5
| compilation main.c
main.c: In function main:
main.c:18: warning: implicit declaration of function printf
main.c:18: warning: incompatible implicit declaration of built-in function printf
Cr�ation ex�cutable : bin/main |
pourtant si je lance le programme cela fonctionne plutôt bien :
Code:
1 2 3 4 5 6 7
| ./main mot1 mot2 mot3 mot4 mot5
argument : ./main
argument : mot1
argument : mot2
argument : mot3
argument : mot4
argument : mot5 |
Mais bon j'ai essayé de faire un truc encore plus simple en créeant des variables int et de les ajoutes dans ma list pour les afficher :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| #include
int main()
{
const int val1 = 10,val2 = 20, val3 = 30, val4 = 40;
Eina_List *list = NULL, *l = NULL;
int *data;
eina_init();
list = eina_list_append(list, val1);
list = eina_list_append(list, val2);
list = eina_list_append(list, val3);
list = eina_list_append(list, val4);
EINA_LIST_FOREACH(list, l, data)
printf(argument : %d\n, data);
return 0;
} |
a la compile j’ai ces erreurs :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| compilation main.c
main.c: In function main:
main.c:13: warning: passing argument 2 of eina_list_append makes pointer from integer without a cast
/home/Mika2008/usr/E17svn/include/eina-0/eina/eina_list.h:78: note: expected const void * but argument is of type int
main.c:14: warning: passing argument 2 of eina_list_append makes pointer from integer without a cast
/home/Mika2008/usr/E17svn/include/eina-0/eina/eina_list.h:78: note: expected const void * but argument is of type int
main.c:15: warning: passing argument 2 of eina_list_append makes pointer from integer without a cast
/home/Mika2008/usr/E17svn/include/eina-0/eina/eina_list.h:78: note: expected const void * but argument is of type int
main.c:16: warning: passing argument 2 of eina_list_append makes pointer from integer without a cast
/home/Mika2008/usr/E17svn/include/eina-0/eina/eina_list.h:78: note: expected const void * but argument is of type int
main.c:19: warning: implicit declaration of function printf
main.c:19: warning: incompatible implicit declaration of built-in function printf
main.c:19: warning: format %d expects type int, but argument 2 has type int *
Cr�ation ex�cutable : bin/main |
et pourtant quand je lance mon programme il marche :
Code:
1 2 3 4 5
| Mika2008@Mika2008-desktop:/media/Element/programmation/SYSTEM/TEST_EINA_LIST/bin$ ./main
argument : 10
argument : 20
argument : 30
argument : 40 |
Donc ma question est comment ne plus avoir ces warnins ?
et est ce que dans une EINA_LIST on peut mettre des variables de type différentes ?
et surtout ce que je comprend pas cette histoire "*"
merci à vous