CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

const array of structs

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rdwebb



Joined: 04 Feb 2005
Posts: 1

View user's profile Send private message

const array of structs
PostPosted: Fri Feb 04, 2005 4:28 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Feb 04, 2005 9:00 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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