Help with warnings

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
secs
Posts: 71
Joined: Fri Jul 31, 2015 9:21 pm
Has thanked: 2 times
Been thanked: 12 times
Contact:

Help with warnings

Post 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

Richard
Posts: 9
Joined: Sun Jan 10, 2016 7:18 pm
Has thanked: 2 times
Been thanked: 4 times
Contact:

Re: Help with warnings

Post by Richard »

Hi Peter,

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

Richard

secs
Posts: 71
Joined: Fri Jul 31, 2015 9:21 pm
Has thanked: 2 times
Been thanked: 12 times
Contact:

Re: Help with warnings

Post 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....

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Help with warnings

Post 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

Post Reply