[En-Nut-Discussion] stm32_can.c fails to build

Harald Kipp harald.kipp at egnite.de
Sat Aug 18 15:38:15 CEST 2012


Hi Uwe,

On 17.08.2012 22:31, Uwe Bonnes wrote:
>>>>>> "Harald" == Harald Kipp <harald.kipp at egnite.de> writes:
> 
>     Harald> 'StmCanSendMsg': ../.././nut/arch/cm3/dev/stm/stm32_can.c:867:5:
>     Harald> error: dereferencing type-punned pointer will break
>     Harald> strict-aliasing rules [-Werror=strict-aliasing]
> 
> The trouble case is, where 4 consequitive bytes of the can frame data
> payload get mapped to a 32-bit register. The cast worked for me and my gcc ;-)
> 
> Should I write as
>  reg32 = byte[0] | (byte[1] <<8)| (bute[2]<<16) | (byte[3] <<24)
> 
> or is there a better construct?

Recently I had to fix a similar case in md5.c and used this horrible ugly solution:

http://ethernut.svn.sourceforge.net/viewvc/ethernut/trunk/nut/gorp/hashes/md5.c?r1=4116&r2=4250

Your's looks much nicer.

Regards,

Harald

P.S. No I'm sure you are using an English keyboard (bute instead of byte).


More information about the En-Nut-Discussion mailing list