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: Ralph Mason
Subject: Re: [avr-gcc-list] printf'ing a string in program memory
Date: Sat, 13 Dec 2003 05:29:32 +1300
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4

Joerg Wunsch wrote:

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.
I have always used %P for this one. It is support by the EtherNut xxxxf functions.

Ralph



reply via email to

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