no bug

the comparison is being done correctly. the type is Char - this means signed.
#defines are replaced by value at preprocessing time. integer constant
type is assumed to be int

comparing into to char, of course causes char to be extended, as you see
however if the char is 0xFF, it gets extended to 0xFFFF, meaning it
will not be equal to 0xFF

if you want this comparaison to work, change the define to be "-1",
change the type to be "unsigned Char", or change the comparaison to
cast it to unsigned char

On 4/10/08, Luc Le Blanc <[EMAIL PROTECTED]> wrote:
> I have a position union:
>
>  typedef struct
>  {
>     UInt8    type;
>     UInt8    datum;
>
>     union
>     {
>         struct
>         {
>             Int16   altitude;
>             UInt32  northing;
>             UInt32  easting;
>             Char    zone;
>             UInt8   gore;
>
>         } grid;
>
>         struct
>         {
>             Int16   altitude;
>             UInt32  latitude;
>             UInt32  longitude;
>             Boolean south;
>             Boolean east;
>
>         } latLon;
>
>         Int16   altitude;
>
>         Int16   depth;
>
>         struct
>         {
>             float    x, y, z;
>
>         } absolute;
>
>         struct
>         {
>             Int16   altitude;
>             UInt16  unused;
>             float   x, y;
>
>         } spot;
>     };
>  } Position;
>
>  I use the grid case. Both zone and gore contain 0xff (as seen in debugger).
>
>  I have a symbol:
>
>  #define Undefined                   0xff
>
>  yet, when I hit
>
>  if ( position->grid.zone == Undefined )
>     StrPrintF( string, "X %ld%sY %ld",
>                ( position->grid.easting + 50 ) / 100, separator,
>                ( position->grid.northing + 50 ) / 100 );
>
>  the StrPrintF is skipped. Here's the assembler:
>
>  00000214: 102A 000C          move.b    12(a2),d0
>  00000218: 4880               ext.w     d0
>  0000021A: 0C40 00FF          cmpi.w    #255,d0
>  0000021E: 6632               bne.s     *+52           ; 0x00000252
>
>  Go figure.
>
>
>  Luc Le Blanc
>
> --
>  For information on using the ACCESS Developer Forums, or to unsubscribe, 
> please see http://www.access-company.com/developers/forums/
>


-- 
Best Regards,
Dmitry Grinberg
(847) 226 9295

-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to