Re: C4244 Warning with +=

Tech-Archive recommends: Speed Up your PC by fixing your registry



Matt <Matt@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> I'm compiling my code with warning level 4 and i am getting C4244
> warnings: conversion from 'int' to 'unsigned short', possible loss of
> data on code like this:
>
> WORD w1 = 5;
> WORD w2 = 2;
>
> w1 += w2; // <--- generates warning
>
> Both types match - how can i get rid of this warning?

This was discussed at some length, e.g. here

http://groups.google.com/group/microsoft.public.vc.language/browse_frm/thread/95ecc316830c1562/a713ae3345f0c810
http://groups.google.com/group/microsoft.public.vc.language/browse_frm/thread/d95905585ebf6d7c/71dab3957a027827

--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages