
UM013037-1212 Project Menu
Zilog Developer Studio II – Z8 Encore!
User Manual
85
top-level routines to parse a format string are not linked into the project, and only those
lower level routines that are actually used are linked in, rather than every routine that
could be used by a call to
printf. The code size of each routine that calls printf() or
sprintf() is slightly larger than if the Generate Printfs Inline checkbox is deselected,
but this is more than offset by the significant reduction in the size of library functions that
are linked to your application.
To reduce overall code size by selecting this checkbox, the following conditions are neces-
sary:
•
All calls to printf() and sprintf() must use string literals, rather than char*
variables, as parameters. For example, the following code allows the compiler to
reduce the code size:
sprintf ("Timer will be reset in %d seconds", reset_time);
But code such as the following results in larger code:
char * timerWarningMessage;
...
sprintf (timerWarningMessage, reset_time);
•
The vprintf() and vsprintf() functions cannot be used, even if the format string
is a string literal.
If the
Generate Printfs Inline checkbox is selected and these conditions are not met, the
compiler warns you that the code size cannot be reduced. In this case, the compiler gener-
ates correct code, and the execution is significantly faster than with normal
printf calls.
However, there is a net increase in code size because the generated inline calls to lower
level functions require more space with no compensating savings from removing the top-
level functions.
In addition, an application that makes over 100 separate calls of
printf or sprintf
might result in larger code size with the
Generate Printfs Inline checkbox selected
because of the cumulative effect of all of the inline calls. The compiler cannot warn about
this situation. If in doubt, simply compile the application both ways and compare the
resulting code sizes.
The
Generate Printfs Inline checkbox is selected by default.
Bit Field Packing
This drop-down list box can be set to
Backward Compatible, Most Compact, or Normal.
The
Most Compact setting, which is the default for new projects, packs the bit-fields as
tightly as possible. This packing saves data space in your application. The
Normal setting
preserves the declared type of all of the individual bit-fields. That is, in an example such
as:
typedef struct {
char bf1:6;
Kommentare zu diesen Handbüchern