Zilog Z8F0130 Manual de usuario Pagina 115

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 214
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 114
UM013037-1212 Project Menu
Zilog Developer Studio II – Z8 Encore!
User Manual
91
unsigned char uch3 = 128;
int int1;
char ch1 = -2;
int main(void)
{
puts("START");
int1 = uch1 - uch2;
if (int1 != -1)
puts("NOT EQUAL");//nopromote:00FFh != FFFFh
else
puts("EQUAL");//promote: FFFFh == FFFFh
if (uch3 < ch1)
puts("UNSIGNED");//nopromote:(uchar)80h < (uchar)FEh
else
puts("SIGNED");//promote: (int) 128 > (int) -2
puts("DONE.");
}
The following recommended programming practices are good practice in any case for pro-
ducing code that is both correct and efficient. These practices are especially important to
avoid trouble if you are using the deprecated Disable ANSI Promotions option:
Use variables of type char or unsigned char wherever the expected range of values for
the variable is [
-128..127] or [0..255], respectively.
Use explicit casts (to int, unsigned int, long or unsigned long) in which the result of an
expression is expected to overflow the larger of the two operand types. (Even with
ANSI promotions disabled, the compiler automatically promotes a smaller operand so
that the types of the operands match.)
It is good programming practice to use explicit casts, even where automatic promo-
tions are expected.
Explicitly cast constant expressions that you want to be evaluated as char (for exam-
ple,
(char)0xFF).
Librarian Page
The options in the Librarian page are described in this section.
This page is available for Static Library projects only.
To configure the librarian, use the following procedure:
Note:
Vista de pagina 114
1 2 ... 110 111 112 113 114 115 116 117 118 119 120 ... 213 214

Comentarios a estos manuales

Sin comentarios