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

Arrays in 16LF876A

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







Arrays in 16LF876A
PostPosted: Tue Aug 29, 2006 5:50 am     Reply with quote

Using the recommended method BYTE CONST TABLE <var>[] = { <vars>}; gives messages "Expecting an ="; "Expecting a declaration" multiple times for one instance. Declaring the vars as {"string"}, {'c', 'h','a','r'}; {1,2,3,4}; gives the same messages. Also checking the program ROM it is filled with rubbish.
Also using strcpy (although in the header file it says use strcopy, which I used) and strcat, these are completely ignored. The pointers used for strcopy and strcat point to areas of ROM somewhere at the end of the bench. Any Ideas?
Ttelmah
Guest







PostPosted: Tue Aug 29, 2006 6:41 am     Reply with quote

First, lets get the constant declaration to work. The first obvious comment, is the use of <vars>, in the table declaration. You cannot have a variable inside a declaration of a constant table. Constants are declared at compile time, while variables only contain values when the program is running. Also, 'table', in the example, is the _name_ of he variable being declared. You cannot have another 'name' after this (which you seem to be trying to do...).
The correct declarations, which should work, are in the form:
[code]

BYTE CONST name[] = {1,2,3,4,5};
BYTE CONST second_name[] = {"string"};

[/char]
Now, the area declared for these, _will_ 'be filled with rubbish'. On the 16 chips in general, there are no operations to access the program memory. So these declarations will be replaced by a program, to return the required values. There will be about a ten byte header component (basically the same for each declaration), followed by a table of 'retlw' instructions, with each returning one value. The data will not be visible in the ROM.
Strcat, _cannot be used with a constant sting_. Strcpy (or strcopy, they are the same function), can be used with a constant, but no 'pointer' is involved in this. The declaration, has to be internal to the call. So:
[code]

char array[20];

strcpy(array, "constant string");

[/code]
Will work, but you cannot hand an already declared constant string to the function. In V3, there is no such thing as a pointer to a constant string.

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