beautypg.com

Zilog EZ80F916 User Manual

Page 200

background image

UM014423-0607

Using the ANSI C-Compiler

ZiLOG Developer Studio II

eZ80Acclaim!

®

User Manual

180

251 Can't preprocess format to (s)printf

This message is generated when the format parameter to

printf

or

sprintf

is not a

string literal and the inline generation of

printf

calls is requested. For example, the

following code causes this warning:

static char msg1 =

"

x = %4d

"

;

char buff[sizeof(msg1)+4];
sprintf(buff,msg1,x);

// WARNING HERE

This warning is generated because the line of code is processed by the real

printf

or

sprintf

function, so that the primary goal of the inline processing, reducing the code

size by removing these functions, is not met.

When this message is displayed, you have three options:

Deselect the Generate Printfs Inline check box (see “Project Settings—Code
Generation Page” on page 61) so that all
calls to

printf

and

sprintf

are

handled by the real

printf

or

sprintf

functions.

Recode to pass a string literal. For example, the code in the example can be
revised as follows:

define MSG1 "x = %4d"

char buff[sizeof(MSG1)+4];

sprintf(buff,MSG1,x); // OK

Keep the Generate Printfs Inline check box selected and ignore the warning. This
loses the primary goal of the option but results in the faster execution of the calls
to

printf

or

sprintf

that can be processed at compile time, a secondary goal of

the option.

252 Bad format string passed to (s)printf

This warning occurs when the compiler is unable to parse the string literal format and
the inline generation of

printf

calls is requested. A normal call to

printf

or

sprintf

is generated (which might also be unable to parse the format).

253 Too few parameters for (s)printf format

This error is generated when there are fewer parameters to a call to

printf

or

sprintf

than the format string calls for and the inline generation of

printf

calls is

requested. For example:

printf(

"

x = %4d\n

"

);

254 Too many parameters for (s)printf format

This warning is generated when there are more parameters to a call to

printf

or

sprintf

than the format string calls for and the inline generation of

printf

calls is

requested. For example:

printf(

"

x = %4d\n

"

, x, y);

The format string is parsed, and the extra arguments are ignored.

This manual is related to the following products: