| | |
| Stránka: 1 z 1
| [ Príspevkov: 6 ] | |
Autor | Správa |
---|
Registrovaný: 19.06.12 Prihlásený: 11.12.17 Príspevky: 132 Témy: 20 | Napísal expoox: 10.12.2017 19:51 | |
|
Ahoj, mam zadanie doplnit header file (implementovat FIFO zasobnik, ktory ma byt univerzalny co sa datoveho typu tyka) a dostal som predpis funkcii typu Kód: void* pop_from_queue(queue_t *queue) atd... Viete mi prosim poradit ako sa s tymto pracuje ? napr : mam tam strukturu Kód: typedef struct { int end; int size; void *list; } queue_t; a na prikaze Kód: bool push_to_queue(queue_t *queue, void *data){ ... queue->list[queue->end] = data; ... }; (a mnoho dalsich) mi hadze chybu ze s tym nespravne pracujem
_________________ Lenovo IdeaPad G580 *Intel Core i3-2310M 2.10GHz * 4GB RAM * Nvidia GeForce 610M 1GB * 500GB HDD SATA * Windows 10 64-bit || Ubuntu 14.04 |
|
Registrovaný: 15.06.14 Prihlásený: 26.03.24 Príspevky: 17930 Témy: 142 Bydlisko: Bratislava |
Myslím že pri vracani hodnoty stačí pretypovat premennú: Kód: return (void*)output;
_________________ ITX >>> ATX |
|
Registrovaný: 19.06.12 Prihlásený: 11.12.17 Príspevky: 132 Témy: 20 | Napísal autor témy expoox: 11.12.2017 13:37 | |
|
return je asi jediny prikaz kde mi nehadze chybu
_________________ Lenovo IdeaPad G580 *Intel Core i3-2310M 2.10GHz * 4GB RAM * Nvidia GeForce 610M 1GB * 500GB HDD SATA * Windows 10 64-bit || Ubuntu 14.04 |
|
Registrovaný: 15.06.14 Prihlásený: 26.03.24 Príspevky: 17930 Témy: 142 Bydlisko: Bratislava |
"mi hadze chybu" je velmi presny opis daneho problemu a hocikto by dokazal urcit kde je chyba (no ibaze by mal kristalovu gulu)
_________________ ITX >>> ATX |
|
Registrovaný: 19.06.12 Prihlásený: 11.12.17 Príspevky: 132 Témy: 20 | Napísal autor témy expoox: 11.12.2017 13:43 | |
|
Kód: In file included from queue.c:1: ./queue.h:20:29: warning: invalid application of 'sizeof' to a void type [-Wpointer-arith] sm->list = malloc(sm->size*sizeof(void)); ^ ~~~~~~ ./queue.h:18:2: warning: variable 'sm' is uninitialized when used here [-Wuninitialized] sm->end = 0; ^~ ./queue.h:17:13: note: initialize the variable 'sm' to silence this warning queue_t *sm; ^ = NULL ./queue.h:38:13: warning: subscript of a pointer to void is a GNU extension [-Wpointer-arith] queue->list[queue->end] = data; ~~~~~~~~~~~^ ./queue.h:38:26: error: incomplete type 'void' is not assignable queue->list[queue->end] = data; ~~~~~~~~~~~~~~~~~~~~~~~ ^ ./queue.h:53:20: warning: subscript of a pointer to void is a GNU extension [-Wpointer-arith] help = queue->list[0]; ~~~~~~~~~~~^ ./queue.h:53:7: error: assigning to 'void *' from incompatible type 'void' help = queue->list[0]; ^ ~~~~~~~~~~~~~~ ./queue.h:57:15: warning: subscript of a pointer to void is a GNU extension [-Wpointer-arith] queue->list[i] = queue->list[i+1]; ~~~~~~~~~~~^ ./queue.h:57:32: warning: subscript of a pointer to void is a GNU extension [-Wpointer-arith] queue->list[i] = queue->list[i+1]; ~~~~~~~~~~~^ ./queue.h:57:19: error: incomplete type 'void' is not assignable queue->list[i] = queue->list[i+1]; ~~~~~~~~~~~~~~ ^ ./queue.h:74:21: warning: subscript of a pointer to void is a GNU extension [-Wpointer-arith] return queue->list[idx]; ~~~~~~~~~~~^ ./queue.h:74:10: error: returning 'void' from a function with incompatible result type 'void *' return queue->list[idx]; ^~~~~~~~~~~~~~~~
cely kod ti tu postovat urcite nebudem... napisal som celkom jasne ze potrebujem vysvetlit ako sa pracuje s void* ako s premennou, tak neviem co mas za problem
_________________ Lenovo IdeaPad G580 *Intel Core i3-2310M 2.10GHz * 4GB RAM * Nvidia GeForce 610M 1GB * 500GB HDD SATA * Windows 10 64-bit || Ubuntu 14.04 |
|
Registrovaný: 15.06.14 Prihlásený: 26.03.24 Príspevky: 17930 Témy: 142 Bydlisko: Bratislava |
ziadny problem nemam, neviem ako si na to prisiel. ale popis problemu "hadze chybu" nie je dostatocny absolutne na nic, nie este na najdenie chyby v kode (ktory ani nemam zaujem vidiet) a nie je na urovni akou sa ma vediet programator vyjadrovat ked nieco potrebuje..
najdi si na googli ako sa pracuje s void pointrami a potom sa mozes vratit s takymto pristupom
_________________ ITX >>> ATX |
|
| Stránka: 1 z 1
| [ Príspevkov: 6 ] | |
| Nemôžete zakladať nové témy v tomto fóre Nemôžete odpovedať na témy v tomto fóre Nemôžete upravovať svoje príspevky v tomto fóre Nemôžete mazať svoje príspevky v tomto fóre
|
|