|
|
View previous topic :: View next topic |
Author |
Message |
Jerry Guest
|
Structure Help |
Posted: Tue Feb 15, 2005 8:18 pm |
|
|
This is some sample code that I have found on web.
Can I define a structure this way with this PCH compiler.
Getting error #27 Expression must evaluate to a constant.
This is a portion of code.
Code: |
#include <18F252.h>
#fuses hs, nowdt, noprotect, nolvp, put, NOOSCSEN
#device *=16 icd=TRUE
#device adc=8
#define FONT_COUNT 1
const unsigned char dot_font_table[] = {
/* ' ' charwidth: 2 */
0x00, /* [ ] */
0x00, /* [ ] */
0x00, /* [ ] */
0x00, /* [ ] */
0x00, /* [ ] */
0x00, /* [ ] */
0x00, /* [ ] */
/* '!' charwidth: 2 */
0x00, /* [ ] */
0x80, /* [* ] */
0x80, /* [* ] */
0x80, /* [* ] */
0x00, /* [ ] */
0x80, /* [* ] */
0x00, /* [ ] */
};
const unsigned char font_width_table[] = {
2, /* ' ' */
2, /* '!' */
};
typedef struct
{
char store_width; /* font storage width in bytes */
char font_height; /* font height for storage */
char *font_table; /* font table start address in memory */
char fixed_width; /* fixed width of font. If zero */
/* then use the width table. */
char *width_table; /* variable width table start address */
char charmap_beg; /* start ascii offset in table */
char charmap_end; /* end ascii offset in table */
char char_def; /* code for undefined char code */
} FONT_DEF;
FONT_DEF fonts[FONT_COUNT] = {
{1, 7, dot_font_table, 0, width_width_table,' ','!','!'}};
main()
{
}
Thanks in advance for any help.
Jerry |
|
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Feb 15, 2005 9:35 pm |
|
|
No pointers to constants allowed in CCS. |
|
|
Jerry Guest
|
|
Posted: Tue Feb 15, 2005 9:55 pm |
|
|
What would be the correct syntax if I don't use the constants for tables.
Thanks
Jerry |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Feb 15, 2005 10:13 pm |
|
|
Like this:
Code: |
#include <18F252.h>
#fuses hs, nowdt, noprotect, nolvp, put, NOOSCSEN
#device *=16 icd=TRUE
#device adc=8
#define FONT_COUNT 1
unsigned char dot_font_table[] = {
/* ' ' charwidth: 2 */
0x00, /* [ ] */
0x00, /* [ ] */
0x00, /* [ ] */
0x00, /* [ ] */
0x00, /* [ ] */
0x00, /* [ ] */
0x00, /* [ ] */
/* '!' charwidth: 2 */
0x00, /* [ ] */
0x80, /* [* ] */
0x80, /* [* ] */
0x80, /* [* ] */
0x00, /* [ ] */
0x80, /* [* ] */
0x00, /* [ ] */
};
unsigned char font_width_table[] = {
2, /* ' ' */
2, /* '!' */
};
typedef struct
{
char store_width; /* font storage width in bytes */
char font_height; /* font height for storage */
char *font_table; /* font table start address in memory */
char fixed_width; /* fixed width of font. If zero */
/* then use the width table. */
char *width_table; /* variable width table start address */
char charmap_beg; /* start ascii offset in table */
char charmap_end; /* end ascii offset in table */
char char_def; /* code for undefined char code */
} FONT_DEF;
FONT_DEF fonts[FONT_COUNT] = {
1, 7, dot_font_table, 0, font_width_table,' ','!','!'};
main()
{
}
|
|
|
|
Jerry Guest
|
|
Posted: Tue Feb 15, 2005 10:24 pm |
|
|
Hey Mark;
I get the same error ???
Now what
Thanks Jerry |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Feb 16, 2005 8:22 am |
|
|
Did you copy and paste the code I posted? It compiles just fine for me. |
|
|
Jerry Guest
|
|
Posted: Wed Feb 16, 2005 10:46 pm |
|
|
Thanks |
|
|
|
|
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
|