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

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

Re: [avr-gcc-list] printf'ing a string in program memory


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] printf'ing a string in program memory
Date: Fri, 12 Dec 2003 10:14:38 +0100 (MET)

As "Dmitry K." <address@hidden> wrote:

>> What character were you thinking of using for a string in Flash? I prefer
>> "%z".

>Letter `z' is used (Glibc, ISO C99) as type modifier for `size_t'.

The C standard says under ``Future library directions'':

7.26.9 Input/output <stdio.h>

1 Lowercase letters may be added to the conversion specifiers and
  length modifiers in fprintf and fscanf. Other characters may be used
  in extensions.

Also, `z' /is/ already standardized (as a modifier):

z Specifies that a following d, i, o, u, x, or X conversion specifier
  applies to a size_t or the corresponding signed integer type
  argument; or that a following n conversion specifier applies to a
  pointer to a signed integer type corresponding to size_t argument.

So the correct way would be to use an upper-case conversion specifier
or modifier. The letters that are available are B, C, D, H..K, M..W,
Y, Z.

The first idea is to use %S, but then, if it comes to EEPROM strings,
what next?  I'm more tempted to use %Ps (mnemonic: progmem string) or
%Cs (constant string) for flash, maybe %Zs for EEPROM strings.
-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/


reply via email to

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