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

Structure Help

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







Structure Help
PostPosted: Tue Feb 15, 2005 8:18 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Tue Feb 15, 2005 9:35 pm     Reply with quote

No pointers to constants allowed in CCS.
Jerry
Guest







PostPosted: Tue Feb 15, 2005 9:55 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Tue Feb 15, 2005 10:13 pm     Reply with quote

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







PostPosted: Tue Feb 15, 2005 10:24 pm     Reply with quote

Hey Mark;

I get the same error ???

Now what

Thanks Jerry
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Feb 16, 2005 8:22 am     Reply with quote

Did you copy and paste the code I posted? It compiles just fine for me.
Jerry
Guest







PostPosted: Wed Feb 16, 2005 10:46 pm     Reply with quote

Thanks Very Happy
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