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 support@ccsinfo.com

a compiling error just after I added one more static var!

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



Joined: 29 Aug 2012
Posts: 97

View user's profile Send private message

a compiling error just after I added one more static var!
PostPosted: Mon Jan 14, 2013 11:52 pm     Reply with quote

Hi there, long time no see~

I am using dsPIC22EP256MU814 with CCS compiler version 4.133
I just met an odd scenario and would like to ask you guys if met that before and know the answer,

The thing is, I have a .h file which keeps lots of static vars ( I know it is not a good programming habit), and just after I add one more var such as "static unsigned int16 abcde;", then the compiler bugs somewhere else (a function in other .c file) which did pass compiled before this var added in.

I did following things:
1. I tried different name to name the new var, and I am sure there is no duplicate var in this project.

2. no matter which .h file I put the declaration of that var, same compiling error.

3. Then I deleted one of unused static var in that .h file(which keep lots of static vars), and keep the new added var in. Then it passed the compile.

4. Based on 3, I doubted that it looks CCS put static vars in a particular place in RAM, and that area has some size limitation. However, even I just delete AN unsigned int16 var and add An ARRAY of unsigned int16 vars, it will pass the compile. So it looks the assumption that "size limitation" not quite right.

5. The RAM usage of my program is 33% at worst. I think static vars will be placed in RAM just can not be cleaned by micro and keep staying there, right?

Anyone who met this scenario before?
Thanks a lot
Mark
Ttelmah



Joined: 11 Mar 2010
Posts: 19338

View user's profile Send private message

PostPosted: Tue Jan 15, 2013 1:44 am     Reply with quote

A couple of comments:

These variables (declared outside the main code), are presumably _global_?.
As such, you don't need them to be declared as 'static', unless you require the default behaviour for these, which is to initialise them to 0.

A global variable, is always intrinsically static. A variable declared as 'static', is initialised to zero.

Except for the need for initialisation (which I must admit I'd normally implicitly initialise variables anyway), static would normally only be needed for variables local to a function.

So, for global variables:

static int16 fred;

is equivalent to

int16 fred=0;

The only other difference of a static variable, is that if using linked code modules, a static variable is not visible outside the module.

So I'd start by trying removing the static declarations, provided the variables are initialised elsewhere (avoids wasted code).

I'd guess you are hitting a limit on the actual number of static variables, rather than the memory used by them. You might try something 'silly', like using the command line compiler, with the -M option (which stops a symbol file being generated), since it could be as simple as running out of space for generating this.

You need to report it to CCS.

Best Wishes
naughty_mark



Joined: 29 Aug 2012
Posts: 97

View user's profile Send private message

PostPosted: Tue Jan 15, 2013 3:08 pm     Reply with quote

Thanks for your advice, Ttelmah. I will try to contact with CCS see if they know why.
Ttelmah



Joined: 11 Mar 2010
Posts: 19338

View user's profile Send private message

PostPosted: Tue Jan 15, 2013 3:35 pm     Reply with quote

As another comment for reducing the number of variables, remember it is normally much more logical, to 'group' variables that work together. So (for example), a set of variables configuring a timer, would be much more logically arranged as:
Code:

struct {
    int8 seconds;
    int8 minutes;
    int8 hours;
    int8 day;
    int8 month;
    int16 year;
} clock;

//Rather than codes as separate variables:

int8 seconds;
int8 minutes;
int8 hours;
int8 day;
int8 month;
int16 year;


This may be why other people have not hit the problem, since the actual number of variables becomes a lot less....

Best Wishes
naughty_mark



Joined: 29 Aug 2012
Posts: 97

View user's profile Send private message

PostPosted: Wed Jan 16, 2013 9:58 pm     Reply with quote

Thanks Ttelmah, that is a good idea.
Sad I still hope CCS can fix those bugs, actually I found some when I did my project, really made me upset. Sometimes just a version update, then my code can not pass compile....
Ttelmah



Joined: 11 Mar 2010
Posts: 19338

View user's profile Send private message

PostPosted: Thu Jan 17, 2013 2:22 am     Reply with quote

A search here will find a lot about compiler updates:

General rules are.

1) CCS releases are beta at best.
2) If you are working with a particular compiler, and don't need a feature that appears in a new release, don't 'upgrade'.
3) Always keep the compiler version number used, and the compiler itself _with_ each project.

Basically, CCS have the annoying habit of making dozens of changes, and documenting just one or two. When they fix one problem, they'll often screw up dozens of other things. This is why 'old hands' here, have literally dozens of compilers and can go back to older versions.

Best Wishes
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