Hi All,

I can't pass this complier:

void Boki (unsigned char ABC, unsigned int Data)
{
Boki_SendData(ABC);
Boki_SendData(Data >> 8); //send high byte
Boki_SendData(Data); //send low byte
}


err msg:
warning C4761: integral size mismatch in argument; conversion supplied

Don't know why error here....
Could you please advice how to fix that ?

Thank you very much!

Best regards,
Boki.

RE: Why can't shift variable ? by armancho_x

armancho_x
Thu Jun 08 06:39:01 CDT 2006

Hi,

Of what type is the parameter of Boki_SendData ?


"Boki" wrote:

> Hi All,
>
> I can't pass this complier:
>
> void Boki (unsigned char ABC, unsigned int Data)
> {
> Boki_SendData(ABC);
> Boki_SendData(Data >> 8); //send high byte
> Boki_SendData(Data); //send low byte
> }
>
>
> err msg:
> warning C4761: integral size mismatch in argument; conversion supplied
>
> Don't know why error here....
> Could you please advice how to fix that ?
>
> Thank you very much!
>
> Best regards,
> Boki.
>



--
======
Arman

Re: Why can't shift variable ? by Victor

Victor
Thu Jun 08 08:22:54 CDT 2006

Boki wrote:
> I can't pass this complier:
>
> void Boki (unsigned char ABC, unsigned int Data)
> {
> Boki_SendData(ABC);
> Boki_SendData(Data >> 8); //send high byte
> Boki_SendData(Data); //send low byte
> }
>
>
> err msg:
> warning C4761: integral size mismatch in argument; conversion supplied
>
> Don't know why error here....
> Could you please advice how to fix that ?

First, it's just a warning. You're free to ignore it or disable it if
the program works as you expect it to.

Second, you could simply supply a static_cast there to shut the compiler
up:

Boki_SendData(static_cast<unsigned char>(Data >> 8));
Boki_SendData(static_cast<unsigned char>(Data));

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask



Re: Why can't shift variable ? by Phil

Phil
Thu Jun 08 10:46:02 CDT 2006

Boki wrote:

> Hi All,
>
> I can't pass this complier:
>
> void Boki (unsigned char ABC, unsigned int Data)
> {
> Boki_SendData(ABC);
> Boki_SendData(Data >> 8); //send high byte
> Boki_SendData(Data); //send low byte
> }
>
>
> err msg:
> warning C4761: integral size mismatch in argument; conversion supplied
>
> Don't know why error here....
> Could you please advice how to fix that ?

That is not an error, that is a warning to let you know you MIGHT have a
problem, but the compiler has fixed it so the code will compile and run. You
have two problems I see:

I assume Boki_SendData() accepts type unsigned char, correct? So if you give it
anything other than an unsigned char the compiler will warn you. You can get rid
of the warning by casting the unsigned int values to unsigned char.

However, you have another problem: unsigned int is NOT 16 bits on current
versions of Windows (WIN32), it is 32 bits. So your code above is only sending
half of the bits of Data.

--
Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com

Re: Why can't shift variable ? by Boki

Boki
Thu Jun 08 20:11:17 CDT 2006


Phil Frisbie, Jr. =E5=AF=AB=E9=81=93=EF=BC=9A

> Boki wrote:
>
> > Hi All,
> >
> > I can't pass this complier:
> >
> > void Boki (unsigned char ABC, unsigned int Data)
> > {
> > Boki_SendData(ABC);
> > Boki_SendData(Data >> 8); //send high byte
> > Boki_SendData(Data); //send low byte
> > }
> >
> >
> > err msg:
> > warning C4761: integral size mismatch in argument; conversion supplied
> >
> > Don't know why error here....
> > Could you please advice how to fix that ?
>
> That is not an error, that is a warning to let you know you MIGHT have a
> problem, but the compiler has fixed it so the code will compile and run. =
You
> have two problems I see:
>
> I assume Boki_SendData() accepts type unsigned char, correct? So if you g=
ive it
> anything other than an unsigned char the compiler will warn you. You can =
get rid
> of the warning by casting the unsigned int values to unsigned char.
>
> However, you have another problem: unsigned int is NOT 16 bits on current
> versions of Windows (WIN32), it is 32 bits. So your code above is only se=
nding
> half of the bits of Data.
>
> --
> Phil Frisbie, Jr.
> Hawk Software
> http://www.hawksoft.com

I got it! Thank you very much!

Best regards,
Boki.