avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] String declaration query


From: James Hamilton
Subject: Re: [avr-gcc-list] String declaration query
Date: Sun, 6 Jul 2014 13:09:25 -0400

They may be different under the hood and have subtly different meanings, but both work in Linux GCC and AVR-GCC without the __flash qualifier.  I've seen these statements used interchangeably in Linux C code, for instance.

The relevant question is, what is the behavior of __flash that causes one to work when the other doesn't when compiling for AVR?

~James


On Sun, Jul 6, 2014 at 12:25 PM, Jim Wagner <address@hidden> wrote:
Big Difference. The first defines an array of characters and initializes it with the string "Hello There". In doing so, it even determines the size of the array for you. Note:  there is one more character than you might expect because every C string ends with a null character that you don't see.

The second does not even define a variable. A char just holds one character. But, you have not even specified a variable that the type char applies to.

The two are totally different.

Jim Wagner
Oregon Research Electronics

On Jul 6, 2014, at 9:00 AM, address@hidden wrote:

> Date: Sun, 6 Jul 2014 18:33:40 +0530
> From: Royce Pereira <address@hidden>
> To: "address@hidden" <address@hidden>
> Subject: [avr-gcc-list] String declaration query 
> Hi,
>
> What is the differenence between:
>
> __flash const char myString[] = "Hello There!" ;
>
> and
>
> __flash const char *myString = "Hello There!" ;
>
> AFAIK, both should be same, but the 2nd gives the error:
>
> " ... initializer element is not computable at load time"
>
> Am I writing it wrong ?
>
> Thanks.
> --
> Best Regards,
>
> -- Royce Pereira
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]