Re: String declaration query
James Hamilton <[email protected]>
| Newsgroups | gmane.comp.hardware.avr.gcc |
|---|---|
| Message-ID | <CA+GRqLZKEak4ybTZ1KKjo257GmVk99SP+2urJo47_eRp4GXnow@mail.gmail.com> |
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 <[email protected]> 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, [email protected] wrote: > > > Date: Sun, 6 Jul 2014 18:33:40 +0530 > > From: Royce Pereira <[email protected]> > > To: "[email protected]" <[email protected]> > > 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 > > > _______________________________________________ AVR-GCC-list mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/avr-gcc-list