ARM-software / CMSIS-DSP

CMSIS-DSP embedded compute library for Cortex-M and Cortex-A
https://arm-software.github.io/CMSIS-DSP
Apache License 2.0
454 stars 122 forks source link

GCC compiler errors with pendantic flag enabled #160

Closed felixvanoost closed 4 months ago

felixvanoost commented 4 months ago

When compiling CMSIS-DSP using GCC 10.3 with the -pedantic flag enabled, the compiler produces errors due to the presence of extra semicolons in the CFFTINIT_ and RFFTINIT_ macros. One example:

[build] Source/TransformFunctions/arm_cfft_init_q31.c:140:1: note: in expansion of macro 'CFFTINIT_Q31'
[build]   140 | CFFTINIT_Q31(4096,4096);
[build]       | ^~~~~~~~~~~~
[build] Source/TransformFunctions/arm_cfft_init_q31.c:140:24: error: ISO C does not allow extra ';' outside of a function [-Werror=pedantic]
[build]   140 | CFFTINIT_Q31(4096,4096);
[build]       |                        ^

This is happening because the macro definitions all end with semicolons, but an extra semicolon has been added when each macro is called:

#define CFFTINIT_Q31(LEN,LENTWIDDLE)
arm_status arm_cfft_init_##LEN##_q31(
  arm_cfft_instance_q31 * S)
{
    /* Removed for brevity */
};

In arm_cfft_init_q31.c:

CFFTINIT_Q31(4096,4096);

The resulting double semicolons are apparently not allowed in ISO C.

christophe0606 commented 4 months ago

Thanks ! I'll make the correction.

christophe0606 commented 4 months ago

Should be solved in latest commit

felixvanoost commented 4 months ago

@christophe0606 In my testing I found that the double semicolons were only part of the problem. GCC is also unhappy about the use of semicolons following a function definition. Currently these macros expand to something like this:

void myfunc(void)
{
    /* Contents */
};

Which is apparently not strictly ISO C. I was able to resolve the errors for good in PR #163.

christophe0606 commented 4 months ago

Ok. Thank you. So I'll merge your new PR.