Hi!

12-Июн-2006 14:40 [EMAIL PROTECTED] (Blair Campbell) wrote to
[EMAIL PROTECTED]:

BC> +++ cmdinput.c      12 Jun 2006 14:40:49 -0000      1.8
BC> +unsigned mywherex( void )
BC> -    return( int )( *( ( char far * )MK_FP( 0x0040, 0x0050 ) ) + 1 );
BC> +    return( unsigned )( *( ( char far * )MK_FP( 0x0040, 0x0050 ) ) + 1 );

      No, this is _not_ fix, it changes nothing - now, when char is signed,
for value 130 this code returns 65410 (instead -126).

      Again: trouble not in target type (int or unsigned), trouble is that
you use "char" instead explicit "unsigned char" (or its typedef-ed type).
Then, if char is signed type, as in TC/BC, char value _sign-extended_ to any
of int and unsigned (and for unsigned this sign-extended value then treated
as unsigned). Your additional explicit cast ("(int)" or "(unsigned)")
changes there nothing and thus superfluous.

      Try this example:

#include <stdio.h>
char c = 130; unsigned f (void) { return c; }
void main () { printf ("%u\n", f ()); }

This is C/C++ in all their weirdness, which you should know...

BC> +static unsigned mywherey( void )
BC> -    return( int )( *( ( char far * )MK_FP( 0x0040, 0x0051 ) ) + 1 );
BC> +    return( unsigned )( *( ( char far * )MK_FP( 0x0040, 0x0051 ) ) + 1 );


_______________________________________________
Freedos-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to