|
|
View previous topic :: View next topic |
Author |
Message |
rdwebb
Joined: 04 Feb 2005 Posts: 1
|
const array of structs |
Posted: Fri Feb 04, 2005 4:28 am |
|
|
Hello all, I've been happily using my old version of the PCWH compiler (version 3.114) for ages. I've now upgraded to version 3.217 of the compiler. Unfortunately some of my code which happily compiled before no longer compiles, and I can't understand why! Here is the code that is causing the problem:
enum tasks { doNothing, doSomething, displayStart, displayEnd };
enum states { first, second, third, fourth };
// Create a struct
struct stateTable
{
tasks task_to_run;
states nextState;
};
// Create an array of structs.
const struct stateTable theTable[2][2] = { { {doNothing, first}, {doSomething, second} },
{ {displayStart, third}, {displayEnd, fourth} } };
This code when compiled gives the error 'Expression must evaluate to a constant'. The code will compile on the old version of the compiler, and will compile on other C compilers .. but not V3.217 that I now have!
Can anyone shed some light on this for me?
Thanks,
Rich. |
|
|
Ken Macfarlane
Joined: 04 Oct 2004 Posts: 12 Location: Glasgow, Scotland
|
|
Posted: Fri Feb 04, 2005 9:00 am |
|
|
I had exactly the same problem, but with an array of 30 structs, each containing 2 strings & some ints: 1080 bytes in all. Some other members suggested in other therads that the compiler will not handle structs bigger than 1024 due to the length of some pointer (smaller than 16 bits long), but I never did get a definitive answer on that, even from CCS. So I chopped my lovely structs up into 4 arrays, and the nasty compiler dragon went back to sleep. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|