EEMEM und Strukturen

#1134157
Lesenswert?

Hallo Zusammen,
ich habe ein kleines Problem mit EEMEM und strukturen ich dort ablegen 
will.

Header-Datei mit der Definition
1
#ifndef COLORDEFINITION_H
2
#define COLORDEFINITION_H
3

4
typedef struct _colorstruc 
5
         {
6
          unsigned char H;
7
          unsigned char S;
8
          unsigned char V;
9
          unsigned char Speed;
10
          unsigned char R;
11
          unsigned char G;
12
          unsigned char B;
13
         } colorstruc;
14

15
typedef struct _colorproc
16
         {
17
          unsigned char prog;
18
          colorstruc colorstruc[10];
19
         } colorproc;
20

21
#endif

c-Datei
1
EEMEM colorproc colortable[10] =
2
  {
3
    {1, { 0x00, 0x00, 0x00, 0x00, 0, 1, 2 } }
4
  };

Als Fehlermeldung erhalte ich

../colordefinition.c:3: error: expected '=', ',', ';', 'asm' or 
'__attribute__' before 'colorproc'

Ich habe schon einiges recherchiert, komme aber nicht weiter.

Wäre für jeden Tip dankbar.

Gruß
Frank
#1134182
Lesenswert?

Hier nochmal ein korrekter Auszug:
1
#ifndef COLORDEFINITION_H
2
#define COLORDEFINITION_H
3

4
typedef struct _colorstruc 
5
         {
6
          unsigned char H;
7
          unsigned char S;
8
          unsigned char V;
9
          unsigned char Speed;
10
          unsigned char R;
11
          unsigned char G;
12
          unsigned char B;
13
         } colorstruc;
14

15
typedef struct _colorproc
16
         {
17
          unsigned char prog;
18
          colorstruc colorstruc[2];
19
             } colorproc;
20

21
#endif
1
#include "colordefinition.h"
2

3
colorproc colortable[1] =
4
  {
5
    { 1, { { 0x00, 0x00, 0x00, 0x00, 0, 1, 2 },
6
           { 0x00, 0x00, 0x00, 0x00, 3, 4, 5 } } }
7
  };

Gruß
Frank
Gast #1134245
Lesenswert?

> colorstruc colorstruc

Ich würd für den Type- und den Variablen-Name verscheiden Bezeichner 
wählen. Ist sicher einfacher zu lesen. Bzw. gewisse Editoren werden mit 
dem Syntax-Highlighting Probleme bekommen.
Gast #1134259
Lesenswert?

Das hier Compiliert bei mir ohne Fehlermeldung
1
#include <avr/eeprom.h>
2

3
typedef struct _colorstruc 
4
         {
5
          unsigned char H;
6
          unsigned char S;
7
          unsigned char V;
8
          unsigned char Speed;
9
          unsigned char R;
10
          unsigned char G;
11
          unsigned char B;
12
         } colorstruc;
13

14
typedef struct _colorproc
15
         {
16
          unsigned char prog;
17
          colorstruc colorstruc[2];
18
             } colorproc;
19

20

21
EEMEM colorproc colortable[1] =
22
  {
23
    { 1, { { 0x00, 0x00, 0x00, 0x00, 0, 1, 2 },
24
           { 0x00, 0x00, 0x00, 0x00, 3, 4, 5 } } }
25
  };
26

27
int main ()
28
{
29

30
  return 0;
31
}

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