Macro "F" passed 2 arguments, but takes just 1

Hi

I’m deploying a project to Artemis module, and I’m using the Arduino library option. While compiling using Arduino 1.8.15 and arm-none-eabi-gcc 8-2018-q4 I get this error. I’m building another TFLM-based project with Mbed studio without throughing this error in comparisons.h.

Error details:

/home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/tools/arm-none-eabi-gcc/8-2018-q4-major/bin/arm-none-eabi-g++ -include /home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/variants/SFE_ARTEMIS_MODULE/mbed/mbed_config.h -include /home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/cores/arduino/sdk/ArduinoSDK.h -iprefix /home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/cores/ @/home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/variants/SFE_ARTEMIS_MODULE/mbed/.cxx-flags -MMD -DARDUINO=10815 -DARDUINO_APOLLO3_SFE_ARTEMIS_MODULE -DARDUINO_ARCH_MBED -DARDUINO_ARCH_APOLLO3 -DMBED_NO_GLOBAL_USING_DIRECTIVE -DCORDIO_ZERO_COPY_HCI @/home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/variants/SFE_ARTEMIS_MODULE/mbed/.cxx-symbols -I/home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/cores/arduino -I/home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/variants/SFE_ARTEMIS_MODULE -I/home/yahya/snap/arduino/current/Arduino/libraries/IMU_inferencing/src -I/home/yahya/snap/arduino/current/Arduino/libraries/DFRobot_BMX160 -I/home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/libraries/Wire/src -I/home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/libraries/SPI/src -I/home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/cores/arduino -I/home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/cores/arduino/mbed-bridge -I/home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/cores/arduino/mbed-bridge/core-api -I/home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/cores/arduino/mbed-bridge/core-api/api/deprecated @/home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/variants/SFE_ARTEMIS_MODULE/mbed/.includes /home/yahya/snap/arduino/current/Arduino/libraries/IMU_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/dequantize.cpp -o /tmp/arduino_build_281072/libraries/IMU_inferencing/edge-impulse-sdk/tensorflow/lite/micro/kernels/dequantize.cpp.o
In file included from /home/yahya/snap/arduino/current/Arduino/libraries/IMU_inferencing/src/edge-impulse-sdk/tensorflow/lite/micro/kernels/comparisons.cpp:15:
/home/yahya/snap/arduino/current/Arduino/libraries/IMU_inferencing/src/edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/comparisons.h:64:54: error: macro "F" passed 2 arguments, but takes just 1
     output_data[i] = F(input1_data[i], input2_data[i]);
                                                      ^
/home/yahya/snap/arduino/current/Arduino/libraries/IMU_inferencing/src/edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/comparisons.h:105:60: error: macro "F" passed 2 arguments, but takes just 1
     output_data[i] = F(scaled_input1_val, scaled_input2_val);
                                                            ^
/home/yahya/snap/arduino/current/Arduino/libraries/IMU_inferencing/src/edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/comparisons.h:147:70: error: macro "F" passed 2 arguments, but takes just 1
                 input2_data[SubscriptToIndex(dims.desc2, b, y, x, c)]);
                                                                      ^
/home/yahya/snap/arduino/current/Arduino/libraries/IMU_inferencing/src/edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/comparisons.h:205:53: error: macro "F" passed 2 arguments, but takes just 1
               F(scaled_input1_val, scaled_input2_val);
                                                     ^

I founded it reported here too: https://forum.sparkfun.com/viewtopic.php?t=55301

It seems the current work arround (not portable for sure) is to rename the template F to any onther name at decleration and usage in comparisons.h. I used FOO name instead.

I reported this to TFLM team too.

@yahyatawil Thanks for this information. I have the same problem. I will give this a try.

The second error after solving the F macro issue is a linking error of multiple definition of symbols as edge-impulse-sdk and Sparkfun Artemis Arduino core have both CMSIS folder.
edge-impulse-sdk/CMSIS and SparkFun/hardware/apollo3/2.1.1/cores/mbed-os/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/sdk/CMSIS/.

Example log:

/home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/tools/arm-none-eabi-gcc/8-2018-q4-major/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: /home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/cores/mbed-os/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/sdk/CMSIS/ARM/Lib/ARM/libarm_cortexM4lf_math.a(arm_const_structs.o):C:\Users\clamar01\fork3\CMSIS_5\CMSIS\DSP\Projects\GCC/../../Source/CommonTables/arm_const_structs.c:475: multiple definition of `arm_rfft_sR_q15_len8192'; /tmp/arduino_build_848098/libraries/IMU_inferencing/edge-impulse-sdk/CMSIS/DSP/Source/CommonTables/objs.a(arm_const_structs.c.o):(.rodata.arm_rfft_sR_q15_len8192+0x0): first defined here
/home/yahya/snap/arduino/61/.arduino15/packages/SparkFun/hardware/apollo3/2.1.1/cores/mbed-os/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/sdk/CMSIS/ARM/Lib/ARM/libarm_cortexM4lf_math.a(arm_const_structs.o):(.rodata.arm_cfft_sR_q31_len64+0x0): multiple definition of `arm_cfft_sR_q31_len64'; /tmp/arduino_build_848098/libraries/IMU_inferencing/edge-impulse-sdk/CMSIS/DSP/Source/CommonTables/objs.a(arm_const_structs.c.o):(.rodata.arm_cfft_sR_q31_len64+0x0): first defined here
....
C:\Users\clamar01\fork3\CMSIS_5\CMSIS\DSP\Projects\GCC/../../Source/BasicMathFunctions/arm_abs_f32.c:67: multiple definition of `arm_abs_f32'; /tmp/arduino_build_848098/libraries/IMU_inferencing/edge-impulse-sdk/CMSIS/DSP/Source/BasicMathFunctions/objs.a(arm_abs_f32.c.o):arm_abs_f32.c:(.text.arm_abs_f32+0x0): first defined here

I finally managed to compile it with Arduino IDE using Sparkfun Artemis core. I solved the duplication in symbols by removing the following line in platform.txt from SparkFun/hardware/apollo3/2.1.1/platform.txt ( platform.txt for each core have some settings for building steps). Comment out libs.extra and remove it from libs.all as well.

#libs.extra=-Wl,--whole-archive "{cores.path}/mbed-os/targets/TARGET_Ambiq_Micro    /TARGET_Apollo3/sdk/CMSIS/ARM/Lib/ARM/libarm_cortexM4lf_math.a" -Wl,--no-whole-archive
libs.all={libs.core} {libs.mbed} {libs.variant} 

I don’t know who should solve this issue from his side (EI or Sparkfun), but hope this gives a workarround until it is officially solved.