Page 1 of 1

Help with warnings

Posted: Thu Jan 07, 2016 5:56 pm
by secs
Hi all.

In a macros I use to read and write to the Eprom of an Arduino I get the follwing warnings when compiling to HEX
C:\Users\peter\Dropbox\projects\flowcode\AQUAPO~1\aqua4.c: In function 'FCM_eprom_read':
C:\Users\peter\Dropbox\projects\flowcode\AQUAPO~1\aqua4.c:10240: warning: left shift count >= width of type
C:\Users\peter\Dropbox\projects\flowcode\AQUAPO~1\aqua4.c:10241: warning: left shift count >= width of type


What does this mean?

Peter

Re: Help with warnings

Posted: Mon Jan 11, 2016 5:53 am
by Richard
Hi Peter,

Can you post your code please so we may be able to help.

Richard

Re: Help with warnings

Posted: Mon Jan 11, 2016 4:42 pm
by secs
I found its within this section of code
Dout, Dout2, Dout3, Dout4 are all Ulong

--------- -------------------------------
Recombine the bytes into an INT:

DOUT4 = Data_out4 << 24
DOUT3 = Data_out3 << 16
DOUT2 = Data_Out2 << 8
DOUT = DOUT4 + DOUT3 + DOUT2
DOUT = DOUT | Data_Out
.Return = Dout
----------------------------------------

I used an example of saving a 32 bit number (I think) into 4 positions of an eprom. If I delete the calculation with this in it, the warnings go away.

I have been writing the code for weeks and just using the simulation to test it. Its only in the last week I have decided to compile to see if it works. I dont even use the macro that this is in for now....

Re: Help with warnings

Posted: Mon Jan 18, 2016 12:56 pm
by Benj
Hello,

Doing this has problems.
DOUT4 = Data_out4 << 24
DOUT3 = Data_out3 << 16
Mainly because most C compilers will default calculations to 16-bit.

If you were doing this in C code then you would do this to force the compilers hand and make the calculation 32-bit.

Code: Select all

DOUT4 = (long) Data_out4 << 24
DOUT3 = (long) Data_out3 << 16
However you can't currently do this in Flowcode so a better way for now might be using multiplication instead. The large numbers should force the calculation to be 32-bit as expected.

Code: Select all

DOUT4 = Data_out4 * 16777216
DOUT3 = Data_out3 * 65536