cancel
Showing results for 
Search instead for 
Did you mean: 

stm32 hal library warning with C++14

Amila Perera
Associate II
Posted on November 30, 2017 at 23:33

Hi all,

I am using stm32 HAL library in a project with C++14 enabled. It issues me the following warning which I can't get rid of.

../platform/stm32/l4/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_rcc.h:735:57:

warning: conversion to void will not access object of type 'volatile uint32_t {aka volatile long unsigned int}'

UNUSED(tmpreg); \

This happens, when a call to __GPIOX_CLK_ENABLE() or __HAL_RCC_GPIOX_CLK_ENABLE is called.

Has anyone been able to get rid of the above warning leaving the HAL source code intact.

Or any ideas as what is possible to be done.

The current warning level is -Wall.

I've experienced the above issue with both l4 & f4 series code.

Thank you in advance.

#firmware-library #stmf4 #firmware #stm32hal #stml4
3 REPLIES 3
Amila Perera
Associate II
Posted on December 04, 2017 at 07:19

I can confirm that this even happens when using eclipse and visualgdb as well.

Therefore I suppose that this is something that is carried along with stm32 source code when C++14 or higher standards is enabled.

Does this mean that STM32 Hal is not updated to work with C++14 or higher standards without warnings.

As for the particular project, I am doing, I am hoping to have zero warnings.

If anyone has a workaround other than falling back to C++11, much appreciated.

Thank you.

bernhard2399
Associate II
Posted on March 15, 2018 at 17:52

I changed:

#define UNUSED(x) ((void)(x))

to

#define UNUSED(x) ((void*)(&x))

and it seems to work. Not 100% sure if it is OK.

Posted on April 23, 2018 at 06:54

Hi Alter,

Thanks for this, but it still seems to need a change in the ST's implementation.

Anyway, I have been able to work around this issue. I could find an acceptable solution by posting this in stackoverflow.

Please have a look at the following.

https://stackoverflow.com/questions/49061212/stm32-hal-library-warning-with-c14-above