11-05-2017, 12:06 PM
The first thing you need to know is that C is NOT portable without a LOT of care. A large part of C is unspecified, undefined and implementation defined parts of C. Refer to your ISO-C language standard annex on portability issue. MISRA-C does go a long way to taming a lot of this but it is not a silver bullet and can only be part of the solution.
A lot of it depends on the compilers you are using. You will need to see the differences between them for the three categories above. This will be in the compiler documentation. Start there.
The page you linked to is for C++. C and C++ are completely different languages with a mainly similar syntax. I am not sure why it talks about converting float to a 32 bit integer. Both x86 and ARM compilers have the float type. You can use Float on ARM MCU's.
Incidentally you are not "cross compiling" but "porting" code designed for one target MCU to a different MCU. A Cross-compiler eg IAR, Keil, GHS etc is a compiler working on a host with one CPU type and compiling code to run on a different target MCU. The code is never intended to run on the host MCU/CPU
A lot of it depends on the compilers you are using. You will need to see the differences between them for the three categories above. This will be in the compiler documentation. Start there.
The page you linked to is for C++. C and C++ are completely different languages with a mainly similar syntax. I am not sure why it talks about converting float to a 32 bit integer. Both x86 and ARM compilers have the float type. You can use Float on ARM MCU's.
Incidentally you are not "cross compiling" but "porting" code designed for one target MCU to a different MCU. A Cross-compiler eg IAR, Keil, GHS etc is a compiler working on a host with one CPU type and compiling code to run on a different target MCU. The code is never intended to run on the host MCU/CPU
<t>This post is made in a personal capacity<br/>
Member of MISRA-C-WG since 2002</t>
Member of MISRA-C-WG since 2002</t>