2004-09-10 Theodore A. Roth [Contributed by Ren Liebscher ] * configure.in (AM_INIT_AUTOMAKE): Bump version. * include/avr/pgmspace.h (PSTR): Fix to allow PSTR to work with C++. Fix for bug #8633. * NEWS: Add note about PSTR fix. Index: NEWS =================================================================== RCS file: /cvsroot/avr-libc/avr-libc/NEWS,v retrieving revision 1.17.2.24 diff -u -p -p -r1.17.2.24 NEWS --- NEWS 9 Sep 2004 16:34:18 -0000 1.17.2.24 +++ NEWS 10 Sep 2004 21:31:17 -0000 @@ -7,6 +7,7 @@ exponent (e. g. "1.234e+"); this also affects scanf as it uses strtod for parsing floating point numbers [#2924] strtod returns incorrect endptr + [#8633] The PSTR() macro doesn't work with C++. [#9013] Macroses as a program block. [#9514] missing stdint.h. [#9669] Incorrect example for strings in flash. Index: configure.in =================================================================== RCS file: /cvsroot/avr-libc/avr-libc/configure.in,v retrieving revision 1.81.2.30 diff -u -p -p -r1.81.2.30 configure.in --- configure.in 9 Sep 2004 16:34:18 -0000 1.81.2.30 +++ configure.in 10 Sep 2004 21:31:17 -0000 @@ -138,7 +138,7 @@ AC_CANONICAL_SYSTEM dnl NOTE: Don't put a '-' in the version number or rpm will puke dnl when building the package. dnl -AM_INIT_AUTOMAKE(avr-libc, 1.0.4.20040909) +AM_INIT_AUTOMAKE(avr-libc, 1.0.4.20040910) AM_CONFIG_HEADER(version.h:version-h.in) AC_DEFINE(__AVRLIBC__,1) Index: include/avr/pgmspace.h =================================================================== RCS file: /cvsroot/avr-libc/avr-libc/include/avr/pgmspace.h,v retrieving revision 1.16.2.3 diff -u -p -p -r1.16.2.3 pgmspace.h --- include/avr/pgmspace.h 16 Apr 2004 18:17:20 -0000 1.16.2.3 +++ include/avr/pgmspace.h 10 Sep 2004 21:31:17 -0000 @@ -102,12 +102,22 @@ typedef uint32_t prog_uint32_t PROGMEM; typedef int64_t prog_int64_t PROGMEM; typedef uint64_t prog_uint64_t PROGMEM; +/* Although in C, we can get away with just using __c, it does not work in + C++. We need to use &__c[0] to avoid the compiler puking. Dave Hylands + explaned it thusly, + + Let's suppose that we use PSTR("Test"). In this case, the type returned + by __c is a prog_char[5] and not a prog_char *. While these are + compatible, they aren't the same thing (especially in C++). The type + returned by &__c[0] is a prog_char *, which explains why it works + fine. */ + /** \ingroup avr_pgmspace \def PSTR(s) 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[0];}) #define __LPM_classic__(addr) \ ({ \