[Top][All Lists]

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

[avr-gcc-list] Defining global PSTR()s

From: Hermann Kraus
Subject: [avr-gcc-list] Defining global PSTR()s
Date: Thu, 05 Jun 2003 14:34:12 +0200
User-agent: Opera7.11/Linux M2 build 406


I have a problem when it try to define something like this as a global variable:
PGM_P main_menu = PSTR("Some text here");

The preprocessor converts it to(without the newlines, of course):
const prog_char * main_menu = ({static char __c[] __attribute__((__progmem__)) = ("Some text here"); __c;});

The compiler's output is:

avr-gcc -c -save-temps -g -O2 -funsigned-char -funsigned-bitfields -fpack- struct -fshort-enums -Wall -Wstrict-prototypes -Werror -Wa,-ahlms=led.lst - mmcu=atmega16 -I. led.c -o led.o led.c:32: error: braced-group within expression allowed only inside a function
led.c:32: warning: type defaults to `int' in declaration of `__c'
led.c:32: warning: data definition has no type or storage class
led.c:32: error: parse error before '}' token
make: *** [led.o] Error 1

As soon as I put in any functions the compiler doesn't complain anymore, but it is not globaly accessible.

Now my questions:
1. Is this really the behavior the PSTR() macro should have???
2. How do I work around it? For the moment I'm using an inline function that returns the pointer but the might be a better soulution.


P.S.: I'm using avr-gcc (GCC) 3.3 20030310 (prerelease)

reply via email to

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