[En-Nut-Discussion] stm32_can.c fails to build
Uwe Bonnes
bon at elektron.ikp.physik.tu-darmstadt.de
Fri Aug 17 22:31:27 CEST 2012
>>>>> "Harald" == Harald Kipp <harald.kipp at egnite.de> writes:
Harald> I got the following problem when trying to build Nut/OS for
Harald> STM32:
Harald> ------------------------------------------------------------------------
Harald> Target : stm32_can-cm3-gcc-bld Command: SET
Harald> PATH=e:\ethernut\nut-trunk\nut\tools\win32;%ProgramFiles(x86)%\yagarto\bin;e:\apps\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;&make
Harald> clean all install Error : 2
Harald> ------------------------------------------------------------------------
Harald> " [CC] ../.././nut/arch/cm3/dev/stm/stm32_can.c"
Harald> ../.././nut/arch/cm3/dev/stm/stm32_can.c: In function
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]
Harald> ../.././nut/arch/cm3/dev/stm/stm32_can.c: In function
Harald> 'CanInput': ../.././nut/arch/cm3/dev/stm/stm32_can.c:941:5:
Harald> error: dereferencing type-punned pointer will break
Harald> strict-aliasing rules [-Werror=strict-aliasing] cc1.exe: all
Harald> warnings being treated as errors
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?
Thanks
--
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