|
|
View previous topic :: View next topic |
Author |
Message |
Gerrit
Joined: 15 Sep 2003 Posts: 58
|
Const array in structure |
Posted: Sat Mar 25, 2006 1:32 pm |
|
|
How do I build the next structure
const char test_A[1024] = {0,0,0.......};
const char test_AA[95] = {0,0,0.......};
const char test_B[1024] = {0,0,0.......};
const char test_BB[95] = {0,0,0.......};
struct
struct FONT_DEF
{
char store_width;
char glyph_height;
const char glyph_table[];
char fixed_width;
const char width_table[];
char glyph_beg;
char glyph_end;
char glyph_def;
};
const struct FONT_DEF fonts[FONT_COUNT] = {
#ifdef EN_FIVE_DOT
{1, 7, test, 0, test_A,' ','~','.'},
#endif
#ifdef EN_SIX_DOT
{2, 8, test_B, 0, test_BB,' ','~','.'},
#endif
}
regards,
gerrit |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Sat Mar 25, 2006 3:16 pm |
|
|
First off, what processor are you using?
There are limitations on array sizes in 16F series chips. |
|
|
Gerrit
Joined: 15 Sep 2003 Posts: 58
|
|
Posted: Sat Mar 25, 2006 4:22 pm |
|
|
I'm using a 18F6622 micro.
Sorry for not mentioning.
I want to access som const char arrays indirect via a structure.
I need to memcpy or memmove data from some location in the const char array to a normal char array
Or are ther better ways to do this ?
Gerrit |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sat Mar 25, 2006 7:01 pm |
|
|
Data and program space are different in the pics. You would have to use a pointer to a const array in your struct. However, CCS doesn't support pointers to const so that will not work either. You could just use an int value to specify which const array the struct is using and then use a switch statement on the int value to access the const array. |
|
|
Gerrit
Joined: 15 Sep 2003 Posts: 58
|
|
Posted: Sun Mar 26, 2006 3:20 am |
|
|
Hello Mark,
I thought it would come to this. Only this solution makes me less flexible
in adding members to the structure.
I will think it over and try to make somethink that fits my needs
Thanks to you for replying.
Gerrit
P.S. will version 4 include * to const !! |
|
|
Ttelmah Guest
|
|
Posted: Sun Mar 26, 2006 7:47 am |
|
|
However, it is worth remembering that if the const array, is a simple integer array, you can access this with normal array accesses. This ought (untried...), to allow transfers if needed with a union. So as a example:
Code: |
struct demo {
char str[8];
int16 word;
int8 b;
};
union link {
struct demo sform;
int8 array[11];
};
const union link cvar = {//Initialise here};
struct demo ram_version;
//You then should be able to move the contents of 'cvar', into
//'ram_version', with:
int8 count;
for (count=0;count<sizeof(struct demo);count++)
*(((int8 *)&ram_version)+count)=cvar.array[count];
|
This will need some tidying up, but might be the basis for withdrawing structure blocks from constant declarations, and placing them in RAM as needed.
Best Wishes |
|
|
|
|
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
|