error: expected identifier or '(' before 'volatile'

Gast #1716466
Lesenswert?

Hallo,
Kann jemand netterweise sagen wo der Fehler ist.
Es scheint mir alles korrekt zu sein.

Dank


main.c
-------------------------

#include "main.h"

int main (void){

  while (1){
    ;
  }

  return 0;
}

-------------------------
main.h
-------------------------

#include <stdio.h>
#include <avr/wdt.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#include <string.h>
#include <avr/eeprom.h>



DDRB = (1<<DDB0) | (1<<DDB1);

PORTB = (0<<PB0) | (0<<PB1 ) | (0<<PB2) | (0<<PB3) | (0<<PB4);

ADMUX = (1<<REFS0);


ADCSRA = (1 << ADEN)  | (1 << ADSC ) | (1 << ADPS2) | (1<<ADPS1);


------------------
FehlerMeldung:


Compiling C: main.c
avr-gcc -c -mmcu=attiny13 -I. -gdwarf-2 -DF_CPU=8000000UL -Os 
-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall 
-Wstrict-prototypes -Wa,-adhlns=./main.lst  -std=gnu99 -MMD -MP -MF 
.dep/main.o.d main.c -o main.o
In file included from main.c:2:
main.h:11: error: expected identifier or '(' before 'volatile'
main.h:11: error: expected ')' before '(' token
main.h:13: error: expected identifier or '(' before 'volatile'
main.h:13: error: expected ')' before '(' token
main.h:15: error: expected identifier or '(' before 'volatile'
main.h:15: error: expected ')' before '(' token
main.h:18: error: expected identifier or '(' before 'volatile'
main.h:18: error: expected ')' before '(' token
make.exe: *** [main.o] Error 1
Moderator Persönliche Seite #1716472
Lesenswert?

ich schrieb:
> Kann jemand netterweise sagen wo der Fehler ist.

In der (Nicht-)Beherrschung der Programmiersprache C deinerseits.

In C darf ausführbarer Code grundsätzlich nur innerhalb von Funktionen
auftreten.  Damit verbietet es sich (von inline-Funktionen mal
abgesehen) normalerweise von selbst, derartige Konstrukte in
Header-Dateien unterzubringen.
Gast #1716527
Lesenswert?

Ich danke euch viel mals für die Antworten besondere Dank
für den Groß Meister Jörg Wunsch



Ich habe es abgeändert und es gibt keine Fehler mehr.


--------------------------------------
main.c
--------------------------------------
#include "main.h"

int main (void){

  init_ATiny13();

  while (1){
    ;
  }

  return 0;
}

--------------------------------------
main.h
--------------------------------------

#include <stdio.h>
#include <avr/wdt.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#include <string.h>
#include <avr/eeprom.h>


void init_ATiny13(void)
{

  DDRB = (1<<DDB0) | (1<<DDB1);
  PORTB = (0<<PB0) | (0<<PB1 ) | (0<<PB2) | (0<<PB3) | (0<<PB4);
  ADMUX = (1<<REFS0);
  ADCSRA = (1 << ADEN)  | (1 << ADSC ) | (1 << ADPS2) | (1<<ADPS1);

}
Gast #1717295
Lesenswert?

das einsame semikolon in deiner main-schleife macht sich auch nicht so 
gut, das gehört dort nicht hin. wenn ein block leer sein soll, ist er 
allein ausreichend, da muss nicht zwingend etwas hinein.
1
int main(void) {
2
  init_ATiny13();
3
  
4
  while (1) {
5
  }
6

7
  return 0;
8
}

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