[AVR-GCC] uczulenie na warning ...

Feb 10, 2007 6 Replies

Witam kompilator wywala mi taki blad: "warning: passing arg 2 of `send_data' discards qualifiers from pointer target type"



prototyp: void send_data (FILE *__stream, void *data, size_t len, uint8_t type)



wywolanie: send_data (&rs232, &Sockets, sizeof(Sockets), 0x01)



zmienna: static volatile uint16_t Sockets;



dlaczeo wywala ten blad? moze mi ktos wyjasnic?



podrawiam: Pawel K


Thus wrote Pawel K snipped-for-privacy@kpw.qs.pl>:

A jakiego typu jest rs232?

Paweł

Pawel K napisał(a):

Jakiego typu jest Sockets? Najprawdopodobniej chodzi mu o niejawne rzutowanie Sockets na void*.

Spróbuj napisać: send_data(&rs232, (void*)&Sockets, sizeof(Sockets), 0x01)

Paweł Więcek napisał(a):

chodzi tu o 2gi argument ...

pozdrawiam Pawel K

Virus_7 napisał(a):

to na kiego grzyba jest ten void ?? wiadomo ze w f-cji i tak nadaje typ wskaznika. Pozatym chyba wiem w czym rzec ... jak deklaruje Sockets bez volatile to nie ma ostrzezenia ...

pozdrawiam Pawel K

Pawel K przemówił ludzkim głosem:

Sam sobie odpowiedziałeś na pytanie. Funkcja send_data nie gwarantuje, że Socket zostanie potraktowany jako wskaźnik na dane typu volatile i kompilator przed tym ostrzega.

Ale data+1 to nie bedzie to samo co &Socket+1

Aaa, to chodzi mu o usuniecie volatile.

majac fukcje void send_data (FILE *__stream, void *data, size_t len, uint8_t type)

kompilator nic nie wie ze ma kompilowac tak jakby *data moglo sie w kazdej chwili zmienic.

sprobuj void send_data (FILE *__stream, volatile void *data, size_t len, uint8_t type)

J.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required