Edge impulse C++ library compilation error in XC32 compiler

Hi!
I deployed the edge impulse “Tutorial: Continuous motion recognition” example as a C++ library and tried to import it and compile it in MPLABX with free compiler XC32 v3.01 from microchip for the ATSAML10E16A microcontroller. I followed the guide: https://microchipdeveloper.com/machine-learning:porting-edge-impulse-sdk
But when I finish configuration of the project and without calling any function of the edge impulse SDK in the main.cpp I get the following compilation error:
…/src/edge-impulse-sdk/CMSIS/DSP/Include/arm_math_memory.h:61:33: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
#define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr))

I get the same error when I try to compile the “smartbell-SAMD21-BMI160” MPLABX example project.

Has anyone succesfully compiled an edge impulse c++ library for a microchip ARM microcontroller with XC32 compiler? Does anyone know why I get this compilation error?

Thanks!

Hi @jalberolalluch looks like you’re compiling with -Werror=strict-aliasing - is this a flag you see in your compiler settings? If not, can you post all flags that you see?

Hi @janjongboom. I do not see that flag in the XC32 compiler (last version).
I attach the compiler screens:

Hi, if you disable ‘Make warnings into errors’ for xc32-g++ this will work. But I think you might also be able to set -fno-strict-aliasing in the additional options for xc32-g++.

Hi @janjongboom, thanks for your help but I disabled the “Make warnings into errors” checkbox and I got the same error because it is not a warning but an error. Then I tried to set -fno-strict-aliasing` in the additional options for xc32-g++ but it did not work either.

The output of the compiler says:

…/src/edge-impulse-sdk/CMSIS/NN/Source/NNSupportFunctions/arm_q7_to_q15_reordered_no_shift.c: In function ‘arm_q7_to_q15_reordered_no_shift’:
In file included from …/src/edge-impulse-sdk/CMSIS/DSP/Include/dsp/fast_math_functions.h:30,
from …/src/edge-impulse-sdk/CMSIS/DSP/Include/arm_common_tables.h:33,
from …/src/edge-impulse-sdk/CMSIS/NN/Include/arm_nnsupportfunctions.h:33,
from …/src/edge-impulse-sdk/CMSIS/NN/Source/NNSupportFunctions/arm_q7_to_q15_reordered_no_shift.c:31:
…/src/edge-impulse-sdk/CMSIS/DSP/Include/arm_math_memory.h:61:33: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
#define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr))
^~~~~~~~~~~~~~~~~~~~~~~~~~~
…/src/edge-impulse-sdk/CMSIS/NN/Source/NNSupportFunctions/arm_q7_to_q15_reordered_no_shift.c:106:10: note: in expansion of macro ‘__SIMD32’
__SIMD32(pDst)++ = in2;
^~~~~~~~
…/src/edge-impulse-sdk/CMSIS/DSP/Include/arm_math_memory.h:61:33: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
#define __SIMD32(addr) (
(__SIMD32_TYPE **) & (addr))
^~~~~~~~~~~~~~~~~~~~~~~~~~~
…/src/edge-impulse-sdk/CMSIS/NN/Source/NNSupportFunctions/arm_q7_to_q15_reordered_no_shift.c:107:10: note: in expansion of macro ‘__SIMD32’
*__SIMD32(pDst)++ = in1;
^~~~~~~~
cc1.exe: all warnings being treated as errors
make[2]: *** [build/default/production/_ext/711107984/arm_q7_to_q15_reordered_no_shift.o] Error 255
make[2]: *** Waiting for unfinished jobs…
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
make[2]: Leaving directory ‘C:/Electronica/AI/firmware/AIcompilation.X’
nbproject/Makefile-default.mk:94: recipe for target ‘.build-conf’ failed
make[1]: Leaving directory ‘C:/Electronica/AI/firmware/AIcompilation.X’
nbproject/Makefile-impl.mk:39: recipe for target ‘.build-impl’ failed

BUILD FAILED (exit value 2, total time: 39s)

Hi @jalberolalluch

I disabled the “Make warnings into errors” checkbox and I got the same error because it is not a warning but an error

In most compilers (all that I know of at least) this is a warning, and my bet was that it was turned into an error due to that checkbox.

Now that I realize this, a quick fix would just be disabling EIDSP_USE_CMSIS_DSP macro. You’re not on an ARM target anyway, and this will fall back to software kernels that don’t have any of this dereferencing behavior.

Hi @janjongboom
I am sorry but I removed the EIDSP_USE_CMSIS_DSP=1 macro and I still get the same warning/error.
My target by now is an ATSAML10E16A microcontroller from microchip which is an ARM cortex M23 (lowest power consumption family I believe).

Hmm… Could you drop me the whole project at jan@edgeimpulse.com ?