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

CCS PCH compiler problems V4.065 V3.249

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



Joined: 17 Oct 2005
Posts: 28
Location: Hampshire, UK

View user's profile Send private message

CCS PCH compiler problems V4.065 V3.249
PostPosted: Mon Sep 29, 2008 4:36 am     Reply with quote

Hi folks,

In another posting tacked onto someone else's problem I stated that I had been having problems with code that compiled, but wouldn't run. Generally adding or removing a _single_ character of a string would result in the code running or not running respectively.

Partly due to this I decided to 'upgrade' to V4.065 from V3.249 as my colleague has been using it successfully. However, similar problems occurred and I just 'got used to it' by adding or removing characters from a sacrificial string!

To fill you in a bit more, I am using an 18F8722. I have ~67000 lines of code compiling to 79-100 % RAM and 90% ROM.

I took on a process of #inline'ing functions where they were only used once as a matter of course to try and shrink code where possible.

Recently, I started getting weird errors about #inline prototypes not being found, and could no longer add functions, even empty ones e.g.


Code:

void blah(void)
{
}


I assumed I had hit some form of upper limit on the number of functions/inline functions/etc.

As an experiment I have just gone back to V3.249

Suddenly my code no longer compiled!
Mainly this was due to function prototype mis-matches. I had missed adding a few "#inline"s to various prototypes or their functions.
Plus V3.249 warned me about a suspicious (though benign) signed/unsigned mismatch.

Looks like my short-lived trust in V4.065 has been shattered!

Back to V3.249 for me!

But does anybody have any idea what the weird string problem might be? The strings are of normal length, ~10-30 chars on average. Nothing unusual. Presumably the one extra/less character pushes the code over/under a segment boundary. But why would that cause the code to compile but run/not run?

TIA,

Nige
_________________
No comment! (Can't think of anything interesting to say!)
Neddie
Guest







CCS PCH compiler problems V4.065
PostPosted: Tue Oct 14, 2008 1:43 am     Reply with quote

I have also found bugs with V4.065.
For instance , this routine to clear an array , does not work. Does work in a previous version.
Code:
unsigned char i;
for(i=0;i<50;i++)
{
  array[i] = 0;
}


Stepping through the code with the debugger it is clear that while the code runs , the values in the array are not changed!!
Using this:
Code:

array[0] = 0;
array[1] = 0;
etc....

Works fine!!

Also found other string related bugs!!

V4.065 sucks!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 14, 2008 12:53 pm     Reply with quote

I made the test program shown below, which fills an array with
incrementing values and displays it. Then it zeros the array and
displays it. This code works with vs. 4.065. I ran it in the MPLAB
simulator, and here's the output:
Quote:
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16
17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D
2E 2F 30 31

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00


Here is the test program:
Code:
#include <18F452.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//======================================
void main(void)
{
int8 array[50];
unsigned char i;

// Fill array with incrementing values.
for(i=0;i<50;i++)
{
  array[i] = i;
}

// Display the array.
for(i=0;i<50;i++)
{
  printf("%X ", array[i]);
}

printf("\n\r");

//----------------
// Now zero the array.
for(i=0;i<50;i++)
{
  array[i] = 0;
}

// Display the array.
for(i=0;i<50;i++)
{
  printf("%X ", array[i]);
}

printf("\n\r");

while(1);
}
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Oct 14, 2008 3:04 pm     Reply with quote

Quote:
Generally adding or removing a _single_ character of a string would result in the code running or not running respectively.
What do you mean with 'the code running or not running'? Is the program behaving bad or not starting at all?

Adding or removing a character to a string will change the memory layout. Most of the times when a problem is fixed by such a change it indicates you have a memory corruption problem, one of the most common and hardest to find bugs in C programming.
Double check the sizes of your arrays, most likely you are writing outside array boundaries. A tip for finding the culprit is to check the symbol file (*.sym), take note of the arrays that are declared in memory directly in front of the string that you changed the size of.
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