|
|
View previous topic :: View next topic |
Author |
Message |
davekelly
Joined: 04 Oct 2006 Posts: 53 Location: Berkshire, England
|
string.h errors |
Posted: Mon Oct 30, 2006 9:48 am |
|
|
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
|
|
Posted: Mon Oct 30, 2006 10:21 am |
|
|
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
|
|
Posted: Mon Oct 30, 2006 10:28 am |
|
|
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
|
|
Posted: Mon Oct 30, 2006 10:42 am |
|
|
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
|
|
Posted: Mon Oct 30, 2006 10:47 am |
|
|
Thankyou, you are right (about order).
I haven't found the problem yet, but the string.h is ok when included earlier on. |
|
|
|
|
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
|