Arduino Forum

Using Arduino => Programming Questions => Topic started by: mattlogue on Apr 18, 2019, 04:16 am

Title: Error: expected '}' before '{' token
Post by: mattlogue on Apr 18, 2019, 04:16 am
Error: expected '}' before '{' token

There clearly is a '}' at the end of that first line! Its a 5x35 array. Compiling for an ESP12E. I know i shoud not use String, but is it worse than using char pointers in unallocated mem blocks...

Code: [Select]
const     String    eAddrNames[5][EADDR_SZ] = { { "RESERVED" }
                        { "dailyEmails", "emailsCount", "fanEvery", "fanFor", "fanMode", "fanPostMixTime", "fanTimeout", "HHOffset", "hysteresis", "lastEmailHour", "lastIssueCodeI", "minsFan", "minsCool", "minsHeat", "lock", "MMOffset", "temperature", "temperatureSet", "tempX", "timeBlocks", "tempTimeout", "timeNTP", "lastVersionDayA", "version2A", "version3A", "lastVersionDayB", "version2B", "version3B", "RESERVED_INT", "RESERVED_INT"}
                        { "unlockTime", "codeMS", "epoch", "longmillis", "lastEmailMS", "lastIssueMS", "myResetMS", "RESERVED_LONG", "RESERVED_LONG", "RESERVED_LONG", "RESERVED_LONG", "RESERVED_LONG", "RESERVED_LONG", "RESERVED_LONG", "RESERVED_LONG" }
                          { "APPass", "ATTPass", "BIPass", "RESERVED_CHAR10", "RESERVED_CHAR10", "RESERVED_CHAR10", "RESERVED_CHAR10", "RESERVED_CHAR10", "RESERVED_CHAR10" }
                          { "RESERVED_STRING20", "RESERVED_STRING20", "RESERVED_STRING20", "RESERVED_STRING20" } };
Title: Re: Error: expected '}' before '{' token
Post by: GoForSmoke on Apr 18, 2019, 04:38 am
troll

Code: [Select]

const     String    eAddrNames[5][EADDR_SZ] = { { "RESERVED" }
                        { "dailyEmails", "emailsCount", "fanEvery", "fanFor", "fanMode", "fanPostMixTime", "fanTimeout", "HHOffset", "hysteresis", "lastEmailHour", "lastIssueCodeI", "minsFan", "minsCool", "minsHeat", "lock", "MMOffset", "temperature", "temperatureSet", "tempX", "timeBlocks", "tempTimeout", "timeNTP", "lastVersionDayA", "version2A", "version3A", "lastVersionDayB", "version2B", "version3B", "RESERVED_INT", "RESERVED_INT"}
                        { "unlockTime", "codeMS", "epoch", "longmillis", "lastEmailMS", "lastIssueMS", "myResetMS", "RESERVED_LONG", "RESERVED_LONG", "RESERVED_LONG", "RESERVED_LONG", "RESERVED_LONG", "RESERVED_LONG", "RESERVED_LONG", "RESERVED_LONG" }
                          { "APPass", "ATTPass", "BIPass", "RESERVED_CHAR10", "RESERVED_CHAR10", "RESERVED_CHAR10", "RESERVED_CHAR10", "RESERVED_CHAR10", "RESERVED_CHAR10" }
                          { "RESERVED_STRING20", "RESERVED_STRING20", "RESERVED_STRING20", "RESERVED_STRING20" } };
Title: Re: Error: expected '}' before '{' token
Post by: mattlogue on Apr 18, 2019, 04:48 am
That's hardly helpful.
Title: Re: Error: expected '}' before '{' token
Post by: Montmorency on Apr 18, 2019, 05:25 am
Um, aggregate initializers are supposed to be separated by commas. Where are your commas?

Code: [Select]
const String eAddrNames[5][EADDR_SZ] = { { "RESERVED" }, // <- comma
    { "dailyEmails", "emailsCount", "fanEvery", "fanFor", "fanMode", "fanPostMixTime", "fanTimeout",
      "HHOffset", "hysteresis", "lastEmailHour", "lastIssueCodeI", "minsFan", "minsCool", "minsHeat",
      "lock", "MMOffset", "temperature", "temperatureSet", "tempX", "timeBlocks", "tempTimeout",
      "timeNTP", "lastVersionDayA", "version2A", "version3A", "lastVersionDayB", "version2B",
      "version3B", "RESERVED_INT", "RESERVED_INT"}, // <- comma
      ...
      // and so on
      ...
 };
Title: Re: Error: expected '}' before '{' token
Post by: mattlogue on Apr 18, 2019, 06:14 am
I missed the commas between the dimensions. Darn, thanks!
Title: Re: Error: expected '}' before '{' token
Post by: GoForSmoke on Apr 18, 2019, 12:40 pm
I know i shoud not use String, but is it worse than using char pointers in unallocated mem blocks...

because whatever you do, don't define char arrays then use those or even more, don't put const chars in PROGMEM.

Load up your RAM with data you already have a copy of and be sure to use C++ convenience objects to trash the heap.

Title: Re: Error: expected '}' before '{' token
Post by: mattlogue on Apr 18, 2019, 01:17 pm
Yep
because whatever you do, don't define char arrays then use those or even more, don't put const chars in PROGMEM.

Load up your RAM with data you already have a copy of and be sure to use C++ convenience objects to trash the heap.


Title: Re: Error: expected '}' before '{' token
Post by: GoForSmoke on Apr 18, 2019, 01:23 pm
You should know better after all this time, hence Reply #1.

Quote
That's hardly helpful.
I'm hardly helping you shoot your own foot. Noted.