Hey Experten,
ich sitze hier seit zwei Stunden und kann innerhalb einer Funktion den
Fehler:
"error: expected identifier before '(' token"
einfach nicht finden. Hab schon unterschiedlichste Sachen ausprobiert,
mehrere Foren durchgelesen, aber leider nichts erfolgreiches gefunden.
Das Projekt ist für einen µC ATMEGA8 vorgesehen. Für die Compilierung
verwende ich das AVRStudio4.
Wär echt cool wenn ihr mir helfen könnt.
Vielen Dank!
/*==================================================================
// Progressive Kennlinie
//==================================================================
// Name: ProgressiveKennlinie()
// Funktion: Spannung des Pedals in 256 Schritte umrechnen
// Argument: Volt
//=================================================================*/
unsigned char ProgressiveKennlinie(unsigned int Volt)
{
signed int Progressive_256=0;
unsigned int ProgressiveKennlinie=0;
unsigned char x1=40;
unsigned char y1=10;
unsigned char x2=60;
unsigned char y2=30;
unsigned char x3=80;
unsigned char y3=50;
unsigned char x4=100;
unsigned char y4=70;
unsigned char x5=120;
unsigned char y5=90;
unsigned char x6=140;
unsigned char y6=110;
unsigned char x7=160;
unsigned char y7=130;
unsigned char x8=180;
unsigned char y8=150;
if (Volt<= 26)
{
Progressive_256=0;
}
else if (26<Volt)&&(Volt<=x1) //--> Hier wird der Fehler angezeigt
{
Produkt=(y1)*(Volt-26);
Progressive_256=Produkt/(x1-26);
}
else if (x1 < Volt)&&(Volt <= x2)
{
Produkt=(y2-y1)*(Volt-x1);
Progressive_256=Produkt/(x2-x1)+y1;
}
else if (x2 < Volt)&&(Volt <= x3)
{
Produkt=(y3-y2)*(Volt-x2);
Progressive_256=Produkt/(x3-x2)+y2;
}
else if (x3 < Volt)&&(Volt <= x4)
{
Produkt=(y4-y3)*(Volt-x3);
Progressive_256=Produkt/(x4-x3)+y3;
}
else if (x4 < Volt)&&(Volt <= x5)
{
Produkt=(y5-y4)*(Volt-x4);
Progressive_256=Produkt/(x5-x4)+y4;
}
else if (x5 < Volt)&&(Volt <= x6)
{
Produkt=(y6-y5)*(Volt-x5);
Progressive_256=Produkt/(x6-x5)+y5;
}
else if (x6 < Volt)&&(Volt <= x7)
{
Produkt=(y7-y6)*(Volt-x6);
Progressive_256=Produkt/(x7-x6)+y6;
}
else if (x7 < Volt)&&(Volt <= x8)
{
Produkt=(y8-y7)*(Volt-x7);
Progressive_256=Produkt/(x8-x7)+y7;
}
else (x7 < Volt)&&(Volt <= 255)
{
Produkt=(255-y8)*(Volt-x8);
Progressive_256=Produkt/(255-x8)+y8;
}
return Progressive_256;
}
else if ((26<Volt)&&(Volt<=x1))
Die if-Bedingung gehört in eine Klammer.
Stefan Ernst schrieb: > Die if-Bedingung gehört in eine Klammer. Nicht nur eine, sondern alle. Der Fehler:
1 | if (26<Volt)&&(Volt<=x1) |
ergibt:
1 | if (26<Volt) //so sieht der compiler das if |
2 | &&(Volt<=x1) //das ist für den compiler schon im "wenn wahr"-teil; mit den && kann er so natürlich nichts anfangen |
Richtig:
1 | if ( (26<Volt) && (Volt<=x1) ) //extra klammern außen rum |
Das gleiche musst du natürlich auch bei den ganzen anderen if machen.
arghhhh, ich hab noch an so was trivales gedacht... Hat funktioniert! Herzlichen Dank.
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.