Re: IAR C-compiler for AVR: Array of pointers to strings in flash
From: Mats Kindahl (mats.kindahl_at_nowhere.net)
Date: 02/03/04
- Next message: Jim Stewart: "Re: Easy PCI interfacing"
- Previous message: Uwe Hercksen: "Re: Inexpensive B/W minature video camera that sees IR"
- In reply to: Hans-Bernhard Broeker: "Re: IAR C-compiler for AVR: Array of pointers to strings in flash"
- Next in thread: Hans-Bernhard Broeker: "Re: IAR C-compiler for AVR: Array of pointers to strings in flash"
- Reply: Hans-Bernhard Broeker: "Re: IAR C-compiler for AVR: Array of pointers to strings in flash"
- Reply: Mats Kindahl: "Re: IAR C-compiler for AVR: Array of pointers to strings in flash"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 03 Feb 2004 17:17:42 +0100
Hans-Bernhard Broeker <broeker@physik.rwth-aachen.de> writes:
> Erik Cato <erik.cato@japro.se> wrote:
> > Looking for help from someone with experience with IAR?s C-compiler
> > for AVR (ATmega16/32)
>
> > I want to declare an array with pointers to constant text. And both of
> > the should be in flash-memory, like this.
>
> > __flash char * __flash textTab[] =
> > {
> > "Text1",
> > "Text2",
> > "Text3",
> > "Text4",
> > "Text5",
> > "Text6",
> > "Text7",
> > "Text8",
> > "Text9",
> > };
>
> You forgot to say how this approach failed.
>
> This may just be a bug in that compiler's C extension keyword __flash,
> particularly in how it's parsed, or you may be missing something on
> how it's supposed to be used.
There's a bug in the declaration, it should write:
char __flash * __flash textTab[] = ....
or
__flash char __flash * textTab[] = ...
(I know, this is really confusing.)
The reason is that writing a memory attribute first on the line
associates this memory attribute to every variable being declared (for
pre-ANSI backward compatability reasons).
The warning message emitted is something about "char const *" not
being convertible to "char __flash *" (not very surprising, they are
in completely different address spaces).
The problem is a result of the fact that, according to the ANSI
standard, generic pointers have to be able to point to string literals
and generic pointers cannot point to flash memory.
Best wishes,
Mats Kindahl
-- IAR Systems in Uppsala, Sweden. Any opinions expressed are my own and not those of my company. Spam prevention: contact me at mNaOtSkPiAnM@acm.org or mNaOtSs.kPindAahMl@iar.se, removing the *NO SPAM* from the address.
- Next message: Jim Stewart: "Re: Easy PCI interfacing"
- Previous message: Uwe Hercksen: "Re: Inexpensive B/W minature video camera that sees IR"
- In reply to: Hans-Bernhard Broeker: "Re: IAR C-compiler for AVR: Array of pointers to strings in flash"
- Next in thread: Hans-Bernhard Broeker: "Re: IAR C-compiler for AVR: Array of pointers to strings in flash"
- Reply: Hans-Bernhard Broeker: "Re: IAR C-compiler for AVR: Array of pointers to strings in flash"
- Reply: Mats Kindahl: "Re: IAR C-compiler for AVR: Array of pointers to strings in flash"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|