[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Discarded Qualifiers.
From: |
David Brown |
Subject: |
Re: [avr-gcc-list] Discarded Qualifiers. |
Date: |
Wed, 12 Mar 2003 13:55:45 +0100 |
> Hi all,
>
> After realising that my intermittent linking problem was caused by an
array
> in one source file having the same name as a function in another. I missed
> the warning that the type and size had changed! (I should go back to
naming
> all functions with a preceeding f_ Like pointers p_ )
I hope that was a joke ! Use naming conventions to improve readability, not
as a way to catch type conflicts. You may feel that preceeding pointer
names with "p_" improves the readability, so by all means use it, but
preceeding functions with "f_" will make you program a mess. Use "-W -Wall"
options when compiling and pay attention to the warnings generated.
> I'm moving on to my
> next problem.
>
> I have an array stored in flash as follows
>
> unsigned char test_graphic[] PROGMEM = {16,16,
> 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
> 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff,
> 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff};
>
> whan I call a function with the following prototype
> void put_graphic(unsigned char x, unsigned char y, unsigned char *data);
>
> using the following call
> put_graphic(0,0,test_graphic);
>
> I get a warning message
> warning: Passing arg 3 of `put graphic' discards qualifier from pointer
> target type.
>
> Why?
>
> The program works fine (for the moment.)
>
> I thought that I might need to change unsigned char to PGM_VOID_P as the
> pointer is to flash and not to sram. However that comes up with an
> incompatable pointer type warning.
>
>
> What am I doing wrong?
>
I think you might be best with:
typedef const unsigned char prog_byte PROGMEM;
prog_byte test_graphic[] = {16,16, ...
void put_graphic(unsigned char x, unsigned char y, prog_byte *data);
Remember to use "c = PRG_RDB(data)", not "c = *data" in the implementation
of put_graphic.