MISRA-C:指针、结构体、联合体的安全规范
解析如何安全而高效地应用指针、结构体和联合体。LEARNING GARDEN学习园地0xO1、0x02、0x030x04,Intelread msg0x4321;Mread msg0x1234Motorola18.4ad msg()0x1234《MISRA-C:2004》MISRA一CMISRA-C2.1typedef unionCPUuint8 t bytes4《 MISRA-C:2004》unit32 t read msg(void)iword msg t tmp;18.buteo]tmp wobywell]tmp. wor8ISO Ctmp bytes[l]= read byte;《 MISRA-Ctmp. bytes[2]=- read byte;2004》SO Ctmp. bytesl3= read byte(;return( tmp word)《 MISRA-O:2004》()uint32 t read msg(void )iuint 32 t wordword=((unit32 tread byte())<24word=word (((unit32 t)read byte())<<16);1 MISRA-C: 2004. Guidelines for the use of the c language irword= word (((unit32 t)read byte())<<8)critical systems. The Motor Industry Software Reliability Asword=word| ((unit32 t)read byte())sociation. 2004return( word)2 Harbison Ill. Samuel P, Steele Jr. Guy003enig2.1,20022.22.1 Intel 80x86/4 ISO/ IEC 9899: 1999, International Organization of StandardiPentium(little-endianzation, 199 9)CPUMotorola 68K ( big-endian9.4.http://c-fag-chn.sourceforge.net/ccfag/index.html)CPU:2005-11-21)read byte()paper(@mesne.com.cn(Microcontrollers Embedded System
用户评论