Initialising const chars?

(This is best viewed with a fixed width font)

With one compiler I would use something like:

const char 2darrayofchars[][4] = { 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0xff, 0x02, 0x00, 0x01, 0x02, 0xff, 0x00, 0x01, 0xff, 0xff, 0x00, 0xff, 0x01, 0x02, 0x00, 0x01, 0x02, 0xff, 0x00, 0xff, 0x01, 0xff };

However the SDCC compiler doesn't like this and makes remarks about curly brackets.

The only example I have found is:

char arr2[5][20] = { "Mickey Mouse", "Donald Duck", "Minnie Mouse", "Goofy", "Ted Jensen" };

but naturally this uses strings which is not helpful.

Can anyone point me in the right direction? Is there a best newsgroup for this sort of question?

Reply to
Fred
Loading thread data ...

How about this:

const char a2darrayofchars[][4] = { {0x00, 0x01, 0x02, 0x03}, {0x00, 0x01, 0xff, 0x02}, {0x00, 0x01, 0x02, 0xff}, {0x00, 0x01, 0xff, 0xff}, {0x00, 0xff, 0x01, 0x02}, {0x00, 0x01, 0x02, 0xff}, {0x00, 0xff, 0x01, 0xff} };

Reply to
mark

curly

Many thanks - I thought for a minute I was going mad because I believed I had already tried this. I had indeed and it didn't work.

I get this error

"myprog.c":"line_number": error: struct/union/array '2darrayofchars' :initialisation needs curly braces

I get 3 of these errors per line of constants 28 + one at the last curly brace.

Reply to
Fred

"Fred" wrote in news:4190e2ed$0$27544$ snipped-for-privacy@news.zen.co.uk:

Yes, it is good to remember that identifiers may not start with a number.

--
- Mark ->
--
Reply to
Mark A. Odell

Many thanks again.

Your principle was correct - I had tried this before and can only think on this occasion I altered the "wrong" file.

Reply to
Fred

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.