RTV forum PL | NewsGroups PL

Wyjaśnienie błędu kompilacji w AVR-GCC: 'discarding qualifiers' w funkcji send_data

[AVR-GCC] uczulenie na warning ...

NOWY TEMAT

elektroda NewsGroups Forum Index - Elektronika Polska - Wyjaśnienie błędu kompilacji w AVR-GCC: 'discarding qualifiers' w funkcji send_data

Pawel K
Guest

Sat Feb 10, 2007 12:06 pm   



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

Paweł Więcek
Guest

Sat Feb 10, 2007 12:32 pm   



Thus wrote Pawel K <groups@kpw.qs.pl>:
Quote:
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)

A jakiego typu jest rs232?

Paweł

--
(___) | Pawel Wiecek ------ Coven / Svart ------ http://www.coven.vmh.net/ |
< o o > | <coven@vmh.net> GPG/PGP info in headers GSM: +48603240006 |
\ ^ / | * * If you don't like the answer, * * |
(") | * * you shouldn't have asked the question. -- Abbot |

Virus_7
Guest

Sat Feb 10, 2007 1:00 pm   



Pawel K napisał(a):
Quote:
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)

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

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


--
__ ___ * Pozdrawiam * ____
\ \ / (_)_ _ _ _ ___ |__ | mailto://rot13.ivehf_7@b2.cy/
\ V /| | '_| || (_-< ___ / / http://www.b3d.pl/
\_/ |_|_| \_,_/__/|___|/_/ gg://2812776/

Pawel K
Guest

Sat Feb 10, 2007 2:25 pm   



Paweł Więcek napisał(a):
Quote:
Thus wrote Pawel K <groups@kpw.qs.pl>:
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)

A jakiego typu jest rs232?
chodzi tu o 2gi argument ...


pozdrawiam
Pawel K

Pawel K
Guest

Sat Feb 10, 2007 2:30 pm   



Virus_7 napisał(a):
Quote:
Jakiego typu jest Sockets? Najprawdopodobniej chodzi mu o niejawne
rzutowanie Sockets na void*.

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

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

Zbych
Guest

Sat Feb 10, 2007 3:35 pm   



Pawel K przemówił ludzkim głosem:

Quote:
jak deklaruje Sockets bez volatile to nie ma ostrzezenia ...

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.

J.F.
Guest

Mon Feb 12, 2007 5:01 pm   



On Sat, 10 Feb 2007 14:30:25 +0100, Pawel K wrote:
Quote:
Spróbuj napisać:
send_data(&rs232, (void*)&Sockets, sizeof(Sockets), 0x01)

to na kiego grzyba jest ten void ?? wiadomo ze w f-cji i tak
nadaje typ wskaznika. Pozatym chyba wiem w czym rzec ...

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

Quote:
jak deklaruje Sockets bez volatile to nie ma ostrzezenia ...

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.

elektroda NewsGroups Forum Index - Elektronika Polska - Wyjaśnienie błędu kompilacji w AVR-GCC: 'discarding qualifiers' w funkcji send_data

NOWY TEMAT

Regulamin - Zasady uzytkowania Polityka prywatnosci Kontakt RTV map News map