C-Compiler kaputt?

ts230

Neues Mitglied
21. Aug. 2008
25
0
0
Sprachen
Hallo,
ich hab ein Problem mit meinen C-Funktionen.
So sieht eine aus:
Code:
//***************************************************************
// Function:     draw
// Description:  send a byte to LCD
// Parameters:   value: value to be sent to LCD via SPI
// Return value: -
//***************************************************************
void draw(unsigned char value)
{
   spi(value);
}
Und der Compiler sagt das:
../lcd.c|11|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
Ich hab echt keine Ahnung was da passiert.
In der main.c passiert sowas aber nicht.
Vielleicht gehts in der main.c weil die kein .h-file hat???
Bitte helft mir
 
Hallo,

du nutzt sicherlich GCC (WinAVR). Der eigentliche Fehler befindet sich wahrscheinlich nicht in der vom Compiler angegebenen Fehlerzeile, sondern irgendwo davor. Du hast bestimmt irgendwo ein Semikolon oder eine Klammer vergessen, so dass sich der Compiler beschwert. In deinem kurzen Codeabschnitt kann ich leider nichts fehlerhaftes sehen, hier müßte man mal den ganzen Code ansehen, bzw. selber compilieren. Am besten wäre es, wenn du deine letzten Programmänderungen überprüfst und nach fehlendem Semikolon oder falscher bzw. fehlender Klammerung suchst.

Grüße,
Dirk
 
Das ist die erste Funktion in der lcd.c!
Hier der ganze code:
Code:
#include "lcd.h"
#include "defines.h"

//***************************************************************
// Function:     clearLCD
// Description:  LCD clear screen
// Parameters:   -
// Return value: -
//***************************************************************

void clearLCD(){
   if(fpClearLCD)
   {
      setCursor(0,0);
      (*fpClearLCD)();
      f
      setCursor(0,0);
   }
}


//***************************************************************
// Function:     draw
// Description:  send a byte to LCD
// Parameters:   value: value to be sent to LCD via SPI
// Return value: -
//***************************************************************
void draw(unsigned char value)
{
   spi(value);
}



unsigned char lcdXpos;        // x cursor position for LCD
unsigned char lcdYpos;        // y cursor position for LCD
unsigned int fgColor;    // foreground color for LCD (xRGB)
unsigned int bgColor;    // background color for LCD (xRGB)


//***************************************************************
// Function:     getCursor
// Description:  returns current virtual cursor position of LCD
// Parameters:   *y: pointer to current y position
//               *x: pointer to current x position
// Return value: -
//***************************************************************
void getCursor(unsigned char *y, unsigned char *x)
{
   *x = lcdXpos;
   *y = lcdYpos;
}


//***************************************************************
// Function:     setCursor
// Description:  set virtual cursor position of LCD
// Parameters:   y: y position
//               x: x position
// Return value: -
//***************************************************************
void setCursor(unsigned char y, unsigned char x)
{
   lcdXpos = x;
   lcdYpos = y;
   if(fpCursor)
   {
      (*fpCursor)(y, x);
   }
}


//***************************************************************
// Function:     lcdColor
// Description:  set colors for LCD output
// Parameters:   fc: forground color
//               bc: background color
// Return value: -
//***************************************************************
void lcdColor(unsigned int fc, unsigned int bc)
{
   fgColor = fc;
   bgColor = bc;
}


//***************************************************************
// Function:     displayFlashText
// Description:  show a text stored in flash on LCD
// Parameters:   *c: pointer to text string
// Return value: -
//**************************************************************
/*
void displayFlashText( char *c)
{
   flash unsigned char *pFont;
   unsigned char i, j;
   unsigned char x, y, value, mask;


   getCursor(&y, &x);


   while(*c)
   {
      window_LM15(x, y, x+7, y+13);
      x += 8;
      P_LCD_CD = 0;
      P_LCD_CS = 0;
      pFont = &charMap[((unsigned int)(*c) - 32) * 14];
      for(i = 0; i < 14; i++)
      {struct menuitem Date;

         value = *pFont;
         mask = 0x80;
         for(j = 0; j < 8; j++)
         {
            if(value & mask)
            {
               draw(fgColor >> 8);
               draw(fgColor & 0xFF);
            }
            else
            {
               draw(bgColor >> 8);
               draw(bgColor & 0xFF);
            }
            mask >>= 1;
         }
         pFont++;
      }
      P_LCD_CS = 1;
      c++;
   }
}*/



//***************************************************************
// Function:     lcdChar
// Description:  show a character stored in RAM on LCD
// Parameters:   c: character
// Return value: -
//***************************************************************
void lcdChar(char c)
{
   flash unsigned char *pFont;
   unsigned char i, j;
   unsigned char x, y, value, mask;


   getCursor(&y, &x);

   window_LM15(x, y, x+7, y+13);
   x += 8;
   P_LCD_CD = 0;
   P_LCD_CS = 0;
   pFont = &charMap[((unsigned int)(c) - 32) * 14];
   for(i = 0; i < 14; i++)
   {
      value = *pFont;
      mask = 0x80;
      for(j = 0; j < 8; j++)
      {
         if(value & mask)
         {
            draw(fgColor >> 8);
            draw(fgColor & 0xFF);
         }
         else
         {
            draw(bgColor >> 8);
            draw(bgColor & 0xFF);
         }
         mask >>= 1;
      }
      pFont++;
   }
   P_LCD_CS = 1;

   setCursor(y, x);

}





//***************************************************************
// Function:     lcdText
// Description:  show a text stored in RAM on LCD
// Parameters:   *c: pointer to text string
// Return value: -
//***************************************************************
void lcdText(char *c)
{
   while(*c)
   {
      lcdChar(*c);
      c++;
   }
}


//***************************************************************
// Function:     setPixel
// Description:  draws a pixel on LCD
// Parameters:   x: x coordinate
//               y: y coordinate
// Return value: -
//***************************************************************
void setPixel(unsigned char x, unsigned char y)
{
   setCursor(y, x);
   P_LCD_CD = 0;
   P_LCD_CS = 0;
   draw(fgColor >> 8);
   draw(fgColor & 0xFF);
   P_LCD_CS = 1;
}


//***************************************************************
// Function:     lcdLine
// Description:  draws a line on LCD
// Parameters:   xstart: x start coordinate
//               ystart: y start coordinate
//               xend:   x end coordinate
//               yend:   y end coordinate
// Return value: -
//***************************************************************
void lcdLine(int xstart, int ystart, int xend, int yend)
{
   int x, y, t, dist, xerr, yerr, dx, dy, incx, incy;

/* Entfernung in beiden Dimensionen berechnen */
     dx = xend - xstart;
     dy = yend - ystart;

/* Vorzeichen des Inkrements bestimmen */
     if(dx<0)
     {
       incx = -1;
       dx = -dx;
     }
     else
       incx = dx ? 1 : 0;

     if(dy < 0)
     {
       incy = -1;
       dy = -dy;
     }
     else
       incy = dy ? 1 : 0;

/* feststellen, welche Entfernung größer ist */
     dist = (dx > dy)?dx:dy;

/* Initialisierungen vor Schleifenbeginn */
     x = xstart;
     y = ystart;
     xerr = yerr = (dist) >> 1; //dx;
     // yerr = dist >> 1; //dy1;

/* Pixel berechnen */
     for(t = 0; t < dist; ++t)
     {
       setPixel(x, y);

       xerr += dx;
       yerr += dy;

       if(xerr >= dist)
       {
         xerr -= dist;
         x += incx;
       }

       if(yerr >= dist)
       {
         yerr -= dist;
         y += incy;
       }
     }

     setPixel(xend, yend);
}
Und Alle Fehler:
||=== TS Territoriumssteuerung, Debug ===|
../lcd.c||In function ‘setPixel’:|

../lcd.c|11|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token|
../lcd.c|29|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token|
../lcd.c|49|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token|
../lcd.c|63|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token|
../lcd.c|81|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token|
../lcd.c|146|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token|
../lcd.c|196|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token|
../lcd.c|213|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token|
../lcd.c|233|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token|
../lcd.c|291|error: old-style parameter declarations in prototyped function definition|
../lcd.c|288|error: expected ‘{’ at end of input|

||=== Build finished: 11 errors, 0 warnings ===|


Ach:ich benutze AVR-gcc unter Linux
 


CodeBox C

//***************************************************************
// Function: clearLCD
// Description: LCD clear screen
// Parameters: -
// Return value: -
//***************************************************************
void clearLCD(){
if(fpClearLCD) {
setCursor(0,0);
(*fpClearLCD)();
f
setCursor(0,0);
}
}


Hallo,

ist das in Zeile 11 ein Schreibfehler?

Dirk
 


CodeBox C

//***************************************************************
// Function: clearLCD
// Description: LCD clear screen
// Parameters: -
// Return value: -
//***************************************************************
void clearLCD(){
if(fpClearLCD) {
setCursor(0,0);
(*fpClearLCD)();
f
setCursor(0,0);
}
}


Hallo,

ist das in Zeile 11 ein Schreibfehler?

Dirk
Und außerderm ist das nur hier in der lcd.c
Ohne das "f" gehts immer noch nicht.
 
Hallo,

kannst du lcd.c, lcd.h und defines.h bitte nochmal in einem Beitrag anhängen. Ich versuche die Programmteile selber zu compilieren.

Grüße,
Dirk
 

Über uns

  • Makerconnect ist ein Forum, welches wir ausschließlich für einen Gedankenaustausch und als Diskussionsplattform für Interessierte bereitstellen, welche sich privat, durch das Studium oder beruflich mit Mikrocontroller- und Kleinstrechnersystemen beschäftigen wollen oder müssen ;-)
  • Dirk
  • Du bist noch kein Mitglied in unserer freundlichen Community? Werde Teil von uns und registriere dich in unserem Forum.
  •  Registriere dich

User Menu

 Kaffeezeit

  • Wir arbeiten hart daran sicherzustellen, dass unser Forum permanent online und schnell erreichbar ist, unsere Forensoftware auf dem aktuellsten Stand ist und der Server regelmäßig gewartet wird. Auch die Themen Datensicherheit und Datenschutz sind uns wichtig und hier sind wir auch ständig aktiv. Alles in allem, sorgen wir uns darum, dass alles Drumherum stimmt :-)

    Dir gefällt das Forum und unsere Arbeit und du möchtest uns unterstützen? Unterstütze uns durch deine Premium-Mitgliedschaft!
    Wir freuen uns auch über eine Spende für unsere Kaffeekasse :-)
    Vielen Dank! :ciao:


     Spende uns! (Paypal)