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

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Sat Aug 18 17:35:32 CEST 2012


>>>>> "Harald" == Harald Kipp <harald.kipp at egnite.de> writes:

    Harald> 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?

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

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

    Harald> Your's looks much nicer.

Watch out, I think your solution also stumbles on endienness.

Bye
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------



More information about the En-Nut-Discussion mailing list