struct does not name a typ .... again

hey there,
I have a problem with my struct in my scetch.
When I try to compile this file it says:

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
Arduino: 1.0.5-r2 (Windows 7), Board: "Teensy 3.0"
DCF_test:117: error: 'Tagesdaten' does not name a type
DCF_test:118: error: 'Tagesdaten' does not name a type
DCF_test:119: error: 'Tagesdaten' does not name a type
DCF_test:120: error: 'Tagesdaten' does not name a type
DCF_test:121: error: 'Tagesdaten' does not name a type
DCF_test:122: error: 'Tagesdaten' does not name a type
DCF_test:123: error: 'Tagesdaten' does not name a type
DCF_test:124: error: 'Tagesdaten' does not name a type
DCF_test:125: error: 'Tagesdaten' does not name a type
DCF_test:126: error: 'Tagesdaten' does not name a type
DCF_test:127: error: 'Tagesdaten' does not name a type
DCF_test:128: error: 'Tagesdaten' does not name a type
DCF_test:129: error: 'Tagesdaten' does not name a type
DCF_test:130: error: 'Tagesdaten' does not name a type
DCF_test:131: error: 'Tagesdaten' does not name a type
DCF_test:132: error: 'Tagesdaten' does not name a type
DCF_test:133: error: 'Tagesdaten' does not name a type
DCF_test:134: error: 'Tagesdaten' does not name a type
DCF_test:135: error: 'Tagesdaten' does not name a type
DCF_test:136: error: 'Tagesdaten' does not name a type
DCF_test:137: error: 'Tagesdaten' does not name a type
DCF_test:138: error: 'Tagesdaten' does not name a type
DCF_test:139: error: 'Tagesdaten' does not name a type
DCF_test:140: error: 'Tagesdaten' does not name a type
DCF_test:141: error: 'Tagesdaten' does not name a type
DCF_test:142: error: 'Tagesdaten' does not name a type
DCF_test:143: error: 'Tagesdaten' does not name a type
DCF_test:144: error: 'Tagesdaten' does not name a type
DCF_test:145: error: 'Tagesdaten' does not name a type
DCF_test:146: error: 'Tagesdaten' does not name a type
DCF_test:147: error: 'Tagesdaten' does not name a type
DCF_test:148: error: 'Tagesdaten' does not name a type
DCF_test:149: error: 'Tagesdaten' does not name a type

I tried typedef struct {…} einschaltzeiten; einschaltzeiten Tagesdaten;
I tried struct einschaltzeiten {}; struct einschaltzeiten Tagesdaten;
I tried both in an external header file but all lead to the same result. Nothing works.
I am confused. So, can anyone help me to fix this?

Thanks and regards
Robert.

DCF_test.ino (14.3 KB)

einschaltzeiten Tagesdaten[MAX_TAGE];

...

/**
 * Einträge für die Einzelnen Tage
 */
Tagesdaten[TAG_WINTERRUHE] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[TAG_NORMAL_SZ] = { 0, 30600, 73800, 43200, 57600, 54000, 68400 };
Tagesdaten[TAG_NORMAL_WZ] = { 0, 27000, 70200, 39600, 54000, 50400, 64800 };
Tagesdaten[3]  = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[4]  = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[5]  = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[6]  = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[7]  = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[8]  = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[9]  = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[10] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[11] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[12] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[13] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[14] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[15] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[16] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[17] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[18] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[19] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[20] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[21] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[22] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[23] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[24] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[25] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[26] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[27] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[28] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[29] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[30] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[31] = { 0, 0, 0, 0, 0, 0, 0 };
Tagesdaten[32] = { 0, 0, 0, 0, 0, 0, 0 };

You cannot assign/initialize like that outside a function. In fact that is not the way to initialize an array.

It needs to be something like:

einschaltzeiten Tagesdaten[MAX_TAGE] = { ... };

Where the initial values are where the ... is.

Example of failed code:

int a [2];

a [0] = 4;
a [1] = 2;

void setup () { }
void loop () { }


sketch_aug22a:3: error: expected constructor, destructor, or type conversion before ‘=’ token
sketch_aug22a:4: error: expected constructor, destructor, or type conversion before ‘=’ token

Code that compiles:

int a [2] = { 4, 2 };

void setup () { }
void loop () { }

Thanks. Wanted to keep the code clean but forgot this.

shame