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

string.h errors

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



Joined: 04 Oct 2006
Posts: 53
Location: Berkshire, England

View user's profile Send private message

string.h errors
PostPosted: Mon Oct 30, 2006 9:48 am     Reply with quote

I am porting one of my ByteCraft projects to CCS, V 3.249

Whenever I include the string.h header, I end up with >100 errors in this file alone, generally for 'Expecting a declaration' or 'Expecting a ('

The correct file is being included, as indicated in the MPLAB output window

Anyone have any ideas? I have spent years getting used to the quirks and bugs in the Bytecraft compiler, I hope there aren't as many issues with CCS!
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Mon Oct 30, 2006 10:21 am     Reply with quote

Like any trouble shooting, break the problem down.
comment everything out but a few lines and get that working the way
you think it should work. Then add some code. and repeat..

Thing is that when you fix a problem, you can fix all the others that are similar. And remember that 1 coding error can call out many errors.

I bet this won't be as bad as you think.
davekelly



Joined: 04 Oct 2006
Posts: 53
Location: Berkshire, England

View user's profile Send private message

PostPosted: Mon Oct 30, 2006 10:28 am     Reply with quote

The original file is just under 6000 lines long, so this is a big port!

For the previous version, I had written all of the library code myself (functions such as strcat, as well as I2C, LCD), as I ran out of ROM space and everything had to be customized.

With the CCS I wanted to use their libraries, and I have got down to less than 100 errors, but as soon as included the string.h file it alone generates 100 errors, on virtually every line.

As an example, the following function creates errors

Code:

char *strcopy(char *s1, char *s2)
{
  char *s;

  for (s = s1; *s2 != 0; s++, s2++) {
     *s = *s2;
  }
  *s = *s2;
  return(s1);
}


the char *s line gives 'Expecting an identifier'

for (s = s1; *s2 != 0; s++, s2++) { line gives 'Expecting a declaration'

etc etc
Ttelmah
Guest







PostPosted: Mon Oct 30, 2006 10:42 am     Reply with quote

The 'normal' reason for this, is that there is a fault in one of the lines 'in front' of the include. The include is donw just as if the whole file was typed into the main program. If (for instance), a function declaration is performed, and not correctly formatted, in front of the include, all the functions in the include can give errors.
Start by laying out the front header of the program in the 'standard'CCS format:

include the chip definition file
setup fuses
set clock rate
define RS232/I2C etc., as required
include the other CCS libraries
Now have your type definitions/prototypes
Now have the code as such.

I suspect you will suddenly find the errors disappear from string.h, and appear further down the code.

Best Wishes
davekelly



Joined: 04 Oct 2006
Posts: 53
Location: Berkshire, England

View user's profile Send private message

PostPosted: Mon Oct 30, 2006 10:47 am     Reply with quote

Thankyou, you are right (about order).

I haven't found the problem yet, but the string.h is ok when included earlier on.
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