Managing error strings in C

Karl Heuer karl at ima.isc.com
Tue Jan 22 13:12:05 AEST 1991


In article <1991Jan19.163652.9203 at hemel.bull.co.uk> boyce at hemel.bull.co.uk (David Boyce) writes:
>>[Moving all your text strings, including printf formats, into an external
>>file also allows it to be translated into other natural languages.]
>
>There is a problem here, in that different human languages do not
>necessarily have the same sentence structure.  [So you need to allow argument
>reordering as well.]  Is there anything like this already around?

X/Open has it.  "%4$d" means print the 4th argument in decimal.  Note that the
naive implementation of pulling the nth word from the stack doesn't work even
on a vaxlike architecture, since you really need the nth argument rather than
the nth word.  (E.g. printf("%2$d %3$d %1$f %4$f", 1.0, 2, 3, 4.0) must work.)

Karl W. Z. Heuer (karl at ima.isc.com or uunet!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list