Webserver Code von Ulrich Radig lässt sich unter Linux nicht kompilieren

Gast #3883185
Hallo,
wollte mal den Code von Ulrich auf einen Pollin NETIO draufspielen, 
leider liest sich gestern den Code unter Linux (Mint16) nicht 
kompilieren. Habe gerade in der Firma mit einen Windows PC versuccht 
(WinAVR-20100110), funktioniert einwandfrei!
GCC ist doch das gleiche in Linux und Windows oder nicht? wo könnte ich 
den Fehler suchen? Makefile ist die gleiche.
Gast #3883426
stefan us schrieb:
> Im Prinzip ja, aber WinAVR enthält eine ziemlich alte Version GCC. Was
> nicht schlimm ist, aber anders.

Ob GCC bei WinAVR alt ist spielt (mir) keine Rolle aber sind anders ist 
auf jedem Fall.
Gast #3883852
So, das gibt den Compiler aus:

1
-------- begin --------
2
avr-gcc (GCC) 4.8.1
3
Copyright (C) 2013 Free Software Foundation, Inc.
4
This is free software; see the source for copying conditions.  There is NO
5
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
6

7

8
Compiling: main.c
9
avr-gcc -c -mmcu=atmega32 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.lst  -std=gnu99 main.c -o main.o
10

11
Compiling: usart.c
12
avr-gcc -c -mmcu=atmega32 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=usart.lst  -std=gnu99 usart.c -o usart.o
13

14
Compiling: stack.c
15
avr-gcc -c -mmcu=atmega32 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=stack.lst  -std=gnu99 stack.c -o stack.o
16
stack.c: In function 'stack_init':
17
stack.c:93:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
18
     (*((unsigned long*)&myip[0])) = get_eeprom_value(IP_EEPROM_STORE,MYIP);
19
     ^
20
stack.c:94:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
21
  (*((unsigned long*)&netmask[0])) = get_eeprom_value(NETMASK_EEPROM_STORE,NETMASK);
22
  ^
23
stack.c:95:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
24
  (*((unsigned long*)&router_ip[0])) = get_eeprom_value(ROUTER_IP_EEPROM_STORE,ROUTER_IP);
25
  ^
26
stack.c:98:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
27
  (*((unsigned long*)&broadcast_ip[0])) = (((*((unsigned long*)&myip[0])) & (*((unsigned long*)&netmask[0]))) | (~(*((unsigned long*)&netmask[0]))));
28
  ^
29
stack.c:98:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
30
stack.c:98:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
31
stack.c:98:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
32
stack.c: In function 'get_eeprom_value':
33
stack.c:133:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
34
  if ((*((unsigned long*)&value[0])) == 0xFFFFFFFF)
35
  ^
36
stack.c:137:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
37
  return((*((unsigned long*)&value[0])));
38
  ^
39
stack.c: In function 'check_packet':
40
stack.c:366:13: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
41
             if( ip->IP_Destaddr == *((unsigned long*)&myip[0]) )  // if my IP address 
42
             ^
43
stack.c:378:29: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
44
                             if ((*((unsigned long*)&ping.ip1[0])) == ip->IP_Srcaddr)
45
                             ^
46
stack.c:397:13: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
47
             if (ip->IP_Destaddr == (unsigned long)0xffffffff || ip->IP_Destaddr == *((unsigned long*)&broadcast_ip[0]) ) // if broadcast
48
             ^
49
stack.c:350:29: warning: variable 'tcp' set but not used [-Wunused-but-set-variable]
50
     struct TCP_Header      *tcp;         //Pointer auf TCP_Header
51
                             ^
52
stack.c: In function 'arp_reply':
53
stack.c:550:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
54
         arp->ARP_TIPAddr == *((unsigned long*)&myip[0])) // F�r uns?
55
         ^
56
stack.c:574:13: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
57
             arp->ARP_SIPAddr = *((unsigned long *)&myip[0]);   // Meine IP Adresse = ARP Source
58
             ^
59
stack.c: In function 'arp_request':
60
stack.c:608:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
61
     if ( (dest_ip & (*((unsigned long *)&netmask[0])))==
62
     ^
63
stack.c:609:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
64
        ((*((unsigned long *)&myip[0]))&(*((unsigned long *)&netmask[0]))) )
65
        ^
66
stack.c:609:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
67
stack.c:616:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
68
         dest_ip = (*((unsigned long *)&router_ip[0]));
69
         ^
70
stack.c:623:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
71
     arp->ARP_SIPAddr = *((unsigned long *)&myip[0]);   // MyIP = ARP Source IP
72
     ^
73
stack.c: In function 'make_ip_header':
74
stack.c:765:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
75
     ip->IP_Srcaddr     = *((unsigned long *)&myip[0]);
76
     ^
77

78
Compiling: timer.c
79
avr-gcc -c -mmcu=atmega32 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=timer.lst  -std=gnu99 timer.c -o timer.o
80

81
Compiling: cmd.c
82
avr-gcc -c -mmcu=atmega32 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=cmd.lst  -std=gnu99 cmd.c -o cmd.o
83
cmd.c:72:15: error: variable 'helptext' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
84
  PROGMEM char helptext[] = {
85
               ^
86
cmd.c: In function 'command_ip':
87
cmd.c:138:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
88
  (*((unsigned long*)&myip[0])) = get_eeprom_value(IP_EEPROM_STORE,MYIP);
89
  ^
90
cmd.c:141:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
91
  (*((unsigned long*)&broadcast_ip[0])) = (((*((unsigned long*)&myip[0])) & (*((unsigned long*)&netmask[0]))) | (~(*((unsigned long*)&netmask[0]))));
92
  ^
93
cmd.c:141:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
94
cmd.c:141:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
95
cmd.c:141:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
96
cmd.c: In function 'command_ntp':
97
cmd.c:166:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
98
  (*((unsigned long*)&ntp_server_ip[0])) = get_eeprom_value(NTP_IP_EEPROM_STORE,NTP_IP);
99
  ^
100
cmd.c: In function 'command_net':
101
cmd.c:176:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
102
  (*((unsigned long*)&netmask[0])) = get_eeprom_value(NETMASK_EEPROM_STORE,NETMASK);
103
  ^
104
cmd.c:179:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
105
     (*((unsigned long*)&broadcast_ip[0])) = (((*((unsigned long*)&myip[0])) & (*((unsigned long*)&netmask[0]))) | (~(*((unsigned long*)&netmask[0]))));
106
     ^
107
cmd.c:179:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
108
cmd.c:179:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
109
cmd.c:179:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
110
cmd.c: In function 'command_router':
111
cmd.c:187:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
112
  (*((unsigned long*)&router_ip[0])) = get_eeprom_value(ROUTER_IP_EEPROM_STORE,ROUTER_IP);
113
  ^
114
cmd.c: In function 'command_ping':
115
cmd.c:320:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
116
   (*((unsigned long*)&ping.ip1[0])) = ((variable[0])+((unsigned long)(variable[1])<<8)+((unsigned long)(variable[2])<<16)+((unsigned long)(variable[3])<<24));
117
   ^
118
cmd.c:322:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
119
   arp_request ( (*(unsigned long*)&ping.ip1[0]));
120
   ^
121
cmd.c:326:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
122
   icmp_send( (*(unsigned long*)&ping.ip1[0]),0x08,0x00,1,1);
123
   ^
124
cmd.c: In function 'read_ip_addresses':
125
cmd.c:378:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
126
  (*((unsigned long*)&myip[0]))      = get_eeprom_value(IP_EEPROM_STORE,MYIP);
127
  ^
128
make: Verlasse Verzeichnis '/media/martin/Datenträger/Microkontroller/Testboards/Ulrich Radig/ETH_M32_EX_SOFT/OldDatas/newStack1_2_9'
129
cmd.c:379:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
130
  (*((unsigned long*)&netmask[0]))   = get_eeprom_value(NETMASK_EEPROM_STORE,NETMASK);
131
  ^
132
cmd.c:380:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
133
  (*((unsigned long*)&router_ip[0])) = get_eeprom_value(ROUTER_IP_EEPROM_STORE,ROUTER_IP);
134
  ^
135
cmd.c:382:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
136
  (*((unsigned long*)&broadcast_ip[0])) = (((*((unsigned long*)&myip[0])) & (*((unsigned long*)&netmask[0]))) | (~(*((unsigned long*)&netmask[0]))));
137
  ^
138
cmd.c:382:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
139
cmd.c:382:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
140
cmd.c:382:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
141
make: *** [cmd.o] Fehler 1
142

143
Beendet: 512

-
Gast #3883893
Ich reduziere das mal auf die Fehlermeldungen. Um die Warnungen geht es 
ja nicht.

cmd.c:72:15: error: variable 'helptext' must be const in order to be put 
into read-only section by means of '__attribute__((progmem))'
  PROGMEM char helptext[] = {

Das kenn ich, hatte ich auch in meinem Webserver. Änderes es auf

const char helptext[] PROGMEM = {...}

Dann ist der Compiler zufrieden. Geht dann auch immer noch mit WinAvr.
Gast #3883896
Hallo Martin,

bis auf eines, sind alles "nur" warnungen. Der Fehler liegt in der Zeile

cmd.c:72:15: error: variable 'helptext' must be const in order to be put 
into read-only section by means of '__attribute__((progmem))'
  PROGMEM char helptext[] = {


mach da mal ein PROGMEM cnst char helptext[] ....


Grüße
Gast #3883968
War kurz weg, vielen Dank für die Hilfe.
Nun kommt die nächste :(

1
base64.c:31:14: error: variable 'BASE64CODE' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
2
 PROGMEM char BASE64CODE[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
Gast #3883969
Also muss das gleiche

nicht"Gast" schrieb:
> PROGMEM const char helptext[] ....

Stefan us schrieb:
> const char helptext[] PROGMEM = {...}

probiere ich nacher gleich
Gast #3884131
>Wenn mich jemand kurz erklären könnte wo genau die unterschied liegt
>wäre nett.

Du benutzt einen neueren Compiler.
Das wars schon. Und ob dieses pissige Verhalten des
neueren Compilers gegenüber älteren Sourcecodes
nun wirklich notwendig war? Vermutlich nicht.
Gast #3884190
dativ schrieb:
> Rettet dem Dativ ...

Acht soooo, da liegt den Unterschied? Hm... da wäre ich wirklich nicht 
drauf gekommen.

holger schrieb:
> Du benutzt einen neueren Compiler.
> Das wars schon. Und ob dieses pissige Verhalten des
> neueren Compilers gegenüber älteren Sourcecodes
> nun wirklich notwendig war? Vermutlich nicht.

Alles klar.
Gast #3884778
Hallo,
und was die Warnungen angeht, was kann ich da besser machen? schein alle 
auch gleich zu sein, habe bei Dr. gurkel habe gesucht aber nicht schlau 
geworden.
1
Compiling: main.c
2
avr-gcc -c -mmcu=atmega32 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.lst  -std=gnu99 main.c -o main.o
3

4
Compiling: usart.c
5
avr-gcc -c -mmcu=atmega32 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=usart.lst  -std=gnu99 usart.c -o usart.o
6

7
Compiling: stack.c
8
avr-gcc -c -mmcu=atmega32 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=stack.lst  -std=gnu99 stack.c -o stack.o
9
stack.c: In function 'stack_init':
10
stack.c:93:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
11
     (*((unsigned long*)&myip[0])) = get_eeprom_value(IP_EEPROM_STORE,MYIP);
12
     ^
13
stack.c:94:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
14
  (*((unsigned long*)&netmask[0])) = get_eeprom_value(NETMASK_EEPROM_STORE,NETMASK);
15
  ^
16
stack.c:95:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
17
  (*((unsigned long*)&router_ip[0])) = get_eeprom_value(ROUTER_IP_EEPROM_STORE,ROUTER_IP);
Gast #3884790
naja, sieht so aus als warnt er dich nur das der speicherbreich 
ausserhalb des verfügbaren speicherbereichs stattfinden köönnte da flash 
vom avr < 65636 bytes
Gast #3884932
Einfach die Warnungen abschalten?
Im makefile hinter -Wall dieses einfügen:
 -Wno-strict-aliasing -Wno-unused-but-set-variable

also:
CFLAGS =  ... -Wall -Wno-strict-aliasing -Wno-unused-but-set-variable 
...

Wenn das Prog dann läuft ist alles i.O. und die compiler Ausgabe sieht 
schön aus.
Alternativ alle Stellen mit den Warnungen umschreiben, oder auf eine 
neue Version warten ;-)

Antwort schreiben

Eine eigene Frage? Dieser Thread ist über 12 Jahre alt. Stell sie in einem eigenen Thread – dort lesen mehr Leute mit, und sie wird öfter und schneller beantwortet.

Neuen Thread starten

Eine Lösung, Ergänzung oder Rückmeldung zu diesem Thread? Dann antworte hier.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.