avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] PSTR C++ fix [bug #8633]


From: Rene Liebscher
Subject: [avr-libc-dev] PSTR C++ fix [bug #8633]
Date: Tue, 18 May 2004 09:09:54 +0200
User-agent: KMail/1.5.1

Hi,

I had another look at the problem. It seems g++ just want to have it as a 
pointer. This is what     &(*__c)   does.

But you could do this also by writing

#define PSTR(s) ({static char __c[] PROGMEM = (s); (PGM_P)__c;})

which is better to understand I think. 
(You have to move then this macro behind the PGM_P definition ;-)

Kind regards
Rene Liebscher

> Hi,
> 
> Can someone comment the validity of the attached patch?
> 
> From my testing, it seems to work for C and C++. It's a little hackish
> though and I'm a bit afraid that it might just be hiding some other
> problem with g++.
> 
> ---
> Ted Roth


 #### old patch ####
diff -u -p -p -r1.19 pgmspace.h
--- include/avr/pgmspace.h      16 Apr 2004 17:17:47 -0000      1.19
+++ include/avr/pgmspace.h      20 Apr 2004 20:08:48 -0000
@@ -107,7 +107,7 @@ typedef uint64_t  prog_uint64_t PROGMEM;

     Used to declare a static pointer to a string in program space. */

-#define PSTR(s) ({static char __c[] PROGMEM = (s); __c;})
+#define PSTR(s) ({static char __c[] PROGMEM = (s); &(*__c);})

 #define __LPM_classic__(addr)   \
 ({                              \





reply via email to

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