I came across something similar when I was writing my matrix display
software and used the following workaround:-
This is part of a character map for a 5x7 dot matrix LED driver

<snip>

__code unsigned char table[128][7] = {
{0x01,0x01,0x01,0x0b,0x0f,0x1f,0x1f},   /* 00h Left fire */
{0x00,0x10,0x10,0x1a,0x1a,0x1e,0x1f},   /* 01h Right fire */
{0x00,0x00,0x1b,0x00,0x04,0x11,0x0e},   /* 02h Smiley1 */
{0x00,0x00,0x0a,0x00,0x04,0x11,0x0e},   /* 03h Smiley2 */
{0x11,0x0a,0x04,0x00,0x11,0x0a,0x04},   /* 04h Chevron down */
{0x04,0x0a,0x11,0x00,0x04,0x0a,0x11},   /* 05h Chevron up */
.
.
.
{0x04,0x04,0x04,0x04,0x04,0x04,0x04},   /* 7ch '|' */
{0x08,0x04,0x04,0x02,0x04,0x04,0x08},   /* 7dh '}' */
{0x0a,0x15,0x00,0x00,0x00,0x00,0x00},   /* 7eh '~' */
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},   /* 7fh '<del>' */
};

main()
{

etc...

Basically you can define static arrays but they have to be declared before
they are used and you have to be explicit that they are stored in the code
segment, in this case it just makes my code a bit more unreadable as there
is now 130 or so lines of code before main(). There may be better ways to do
this but this worked for me :-).
I am sure that you can do similar for your strings.

Regards
Graham Clinch


-----Original Message-----
From: Peter Van Epp [mailto:van...@sfu.ca]
Sent: 13 May 2010 20:36
To: sdcc-user@lists.sourceforge.net
Subject: Re: [Sdcc-user] piklab compilation problem


On Thu, May 13, 2010 at 12:57:07AM -0700, Duygu Altinok wrote:
> Hi,
> I'm new to piklab and sdcc   , when I try to compile some stuff our
instructors gave us I get the following error:
>
> sdcc -mpic14 -p16f877 -V --debug -I/home/duygu/ceng4/ -c
ceng336/hw3_lcd_examples/lcd.c
> +
"/usr/bin/sdcpp" -nostdinc -Wall -std=c99 -I"/home/duygu/ceng4/" -obj-ext=.o
 -DSDCC_MODEL_SMALL -DSDCC=280 -DSDCC_REVISION=5117 -DSDCC_pic14 -D__pic14 -
DSDCC_PROCESSOR="16f877" -I"/usr/bin/../share/sdcc/include/pic14" -I"/usr/sh
are/sdcc/include/pic14" -I"/usr/bin/../share/sdcc/include" -I"/usr/share/sdc
c/include" -I"/usr/bin/../share/sdcc/include/pic" -I"/usr/share/sdcc/include
/pic" "ceng336/hw3_lcd_examples/lcd.c"
> sdcc -mpic14 -p16f877 -V --debug -I/home/duygu/ceng4/ -c
ceng336/hw3_lcd_examples/lcd_demo.c
> demo1
> glue.c:1956: emitInitVal: Assertion `!"Initialized char-arrays are not yet
supported, assign at runtime instead."' failed.

<snip>

        It looks to be unable to support this (yet):
>
> static const char demo1[] = "+--------------+";
> static const char demo2[] = "|   Ceng 336   |";
> static const char demo3[] = "| SDCC LCD demo|";
> static const char demo4[] = "+--------------+";
>

        and needs something like this to change the assignment from compile
time to run time as the assert suggested. You probably will neet to add

#include <string.h>

to pick up the strcpy() prototype as well.

> void writeDemo()
> {
>     int i;

      char demo1[20];
      char demo2[20];
      char demo3[20];
      char demo4[20];

      strcpy(demo1,"+--------------+");
      strcpy(demo2,"|   Ceng 336   |");
      strcpy(demo3,"| SDCC LCD demo|");
      strcpy(demo4,"+--------------+");

>     lcdGoto(START_OF_LINE1);
>     for(i = 0; demo1[i]; i++)
>         lcdWrite(demo1[i]);
<snip>

Peter Van Epp

----------------------------------------------------------------------------
--

_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user


------------------------------------------------------------------------------

_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to