Probleme mit delay.h

OP #2764526
Lesenswert?

Hallo Forum,

gerade wollte ich mit C und dem AVR anfangen, und jetzt kriege ich schon 
einen Fehler beim kompilieren und verstehe nicht warum.

mein Program (eh super-kurz):
1
#define F_CPU 3686400UL
2
#include <util/delay.h>
3

4
int main(void)
5
{
6
    while(1)
7
    {
8
        _delay_ms(1000);
9
    }
10
    return 0;
11
}
1
Compiling: main.c
2
avr-gcc -c -mmcu=atmega8 -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.lst  -std=c89 -DF_OSC=3686400 -MD -MP -MF .dep/main.o.d main.c -o main.o 
3
In file included from /usr/lib/gcc/avr/4.3.5/../../../avr/include/util/delay.h:39,
4
                 from main.c:2:
5
/usr/lib/gcc/avr/4.3.5/../../../avr/include/util/delay_basic.h:65: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
6
/usr/lib/gcc/avr/4.3.5/../../../avr/include/util/delay_basic.h:66: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
7
In file included from main.c:2:
8
/usr/lib/gcc/avr/4.3.5/../../../avr/include/util/delay.h:79: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
9
/usr/lib/gcc/avr/4.3.5/../../../avr/include/util/delay.h:80: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
10
make: *** [main.o] Fehler 1

Was ich bis jetzt rausgefunden habe ist, dass es mit dem GNU99 
C-Standard geht, mit ANSI-C nicht. Ist die avr-libc nicht ANSI-C 
tauglich? Ich verwende im Übrigen das template Makefile aus der AVR-GCC 
Tutorial Ecke oben links...

mfg
Thomas
OP #2764540
Lesenswert?

troll schrieb:
> fehlt da nicht ein #include <avr/io.h>?

Ja, den Header werde ich mit Sicherheit noch brauchen. Ändert aber am 
Verhalten nix. ANSI-C scheint nicht zu gehen, mit GNU-Extensions aber 
schon (im Makefile wäre das "gnu89").

Brauchen tu ich das jetzt nicht. Ich dachte halt, es würde mit ANSI-C 
auch gehen, tuts aber eben nicht.

mfg
Thomas
OP #2764750
Lesenswert?

In der Beschreibung der avr-libc steht zu lesen:
1
In general, it has been the goal to stick as best as possible to
2
established standards while implementing this library. Commonly, this
3
refers to the C library as described by the ANSI X3.159-1989 and ISO/IEC
4
9899:1990 ("ANSI-C") standard, as well as parts of their successor ISO/IEC
5
9899:1999 ("C99"). Some additions have been inspired by other standards
6
like IEEE Std 1003.1-1988 ("POSIX.1"), while other extensions are purely
7
AVR-specific (like the entire program-space string interface).

Ich nehme daher an, es ist schon alleine wegen der avr-libc nicht egal 
nach welchem C-Standard man ein Program mit der Makefile-Vorlage 
kompiliert.

mfg
Thomas

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren