cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeIDE: Requesting disabling warning using #pragma before large sized array declaration

RajeevAroraCrcEvans
Associate III

Dear @Khouloud ZEMMELI , @Imen.D  ,

Please connect me with someone to help resolve the below concern.

I have enabled all possible warnings in STM32CubeIDE.

I however just want to disable warning for one large sized constant array (possibly using #pragma <disable_large_size_Array_Warning> and then later enable it back after the constant array declaration is over).

 

 

arm-none-eabi-gcc "../User_Code/xxx.c" -mcpu=cortex-m7 -std=gnu18 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32H753xx -c -I../User_Code -I../Core/Inc -I../Drivers/STM32H7xx_HAL_Driver/Inc -I../Drivers/STM32H7xx_HAL_Driver/Inc/Legacy -I../Middlewares/Third_Party/FreeRTOS/Source/include -I../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F -I../Drivers/CMSIS/Device/ST/STM32H7xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -Wextra -pedantic -Wmissing-include-dirs -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"User_Code/xxx.d" -MT"User_Code/xxx.o" --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -o "User_Code/xxx.o"
../User_Code/xxx.c:209:1: warning: string length '4523' is greater than the length '4095' ISO C99 compilers are required to support [-Woverlength-strings]
  209 | "----------------------------------------------------------------------------------------\r\n";
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

 

 I believe the compiler should be able to provide correct address for the large array and allow its sizeof() to be calculated as well as allow its data to be transmitted over serial.

Please help!

Thanks!

Rajeev

5 REPLIES 5
Andrew Neil
Evangelist III

maybe look at

#pragma GCC diagnostic push
#pragma GCC diagnostic pop

https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html

maybe also 

#pragma push_macro("macro_name")

#pragma pop_macro("macro_name")

https://gcc.gnu.org/onlinedocs/gcc/Push_002fPop-Macro-Pragmas.html

 

@Andrew Neil 

 

Are you aware of the difference between the push_options ans the diagnostic push

I am unable to find a document which helps me use the options both with sTM32CubeIDE and MDK-ARM comiler version 6.

Hence, below is what I've added to the header file.

 

#pragma GCC push_options

 

#pragma GCC diagnostic push

 

#pragma GCC diagnostic ignored "-Wsign-conversion"

 

#include "stm32h7xx_hal.h"

 

#pragma GCC diagnostic pop

 

#pragma GCC pop_options

 

Regards,

Rajeev


@RajeevAroraCrcEvans wrote:

Are you aware of the difference between the push_options ans the diagnostic push


Only that the 2 exist - haven't looked in depth at the differences

 


@RajeevAroraCrcEvans wrote:

use the options both with sTM32CubeIDE and MDK-ARM comiler version 6.


These things are very much proprietary.

You'd probably have to wrap them in conditionals according to compiler; eg,

#if defined KEIL

   // Keil-specific magic here

#elif defined GCC

   // GCC-specific magic here

#else
#error "Unknown compiler"
#endif

(I just invented those symbols - you'd need to check what actually identifies Keil & GCC)

 

@Andrew Neil 

I have enabled extra warnings, because of which when I compile the code using Git Bash a lot of warnings are thrown even for:

#include "stm32h7xx_hal.h"

For now I've added the below line just above the include and have included both in a push-pop

#pragma GCC diagnostic ignored "-Wsign-conversion"

What I am unsure is whether to use the word "diagnostic" or not in above.
I use below conditional compilation so as to use same code in STM32CubeIDE and Keil MDK-ARM:

#if defined(__CC_ARM) || defined(__ARMCC_VERSION)
/* The following flag must be enabled only when using newlib */
#define configX          0
#else // of defined(__CC_ARM) || defined(__ARMCC_VERSION)
#define configX          1
#endif // of defined(__CC_ARM) || defined(__ARMCC_VERSION)

Regards,

Rajeev