I just downloaded GCC 10 with c++20 on my embedded project.
However in embedded applications it's quite common to use volatile for Register Struct Mappers.
Since the compiler does not know if the Register value was changed externally by a DMA, it makes sense to "force" a reload of this register.
To increase performance some of these volatiles are placed in C Header files. When I include these headers in a cpp file, i get lot's of volatile deprecation errors.
Is there any way to disable these errors?
@Edit As requested some example code.
/*!
* @brief Enable the clock for specific IP.
*
* @param name Which clock to enable, see \ref clock_ip_name_t.
*/
static inline void CLOCK_EnableClock(clock_ip_name_t name)
{
uint32_t regAddr = SIM_BASE + CLK_GATE_ABSTRACT_REG_OFFSET((uint32_t)name);
(*(volatile uint32_t *)regAddr) |= (1UL << CLK_GATE_ABSTRACT_BITS_SHIFT((uint32_t)name));
}
C:/xxx/kinetisSDK/2.7.0/devices/MK64F12/drivers/fsl_clock.h:671:37: error: compound assignment with 'volatile'-qualified left operand is deprecated [- Werror=volatile]
671 | (*(volatile uint32_t *)regAddr) |= (1UL << CLK_GATE_ABSTRACT_BITS_SHIFT((uint32_t)name)); |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Since these defines are spread throughout NXP SDK I tried to extract only the necessary parts.
https://godbolt.org/z/WKzj5j
However Godbolt seems to be fine. Maybe it's because I'm using gcc 10 for arm eabi.
You can't use |=
anymore, but you can use =
, so change this:
(*(volatile uint32_t *)regAddr) |= (1UL << CLK_GATE_ABSTRACT_BITS_SHIFT((uint32_t)name));
To this:
*(volatile uint32_t *)regAddr = *(volatile uint32_t *)regAddr | (1UL << CLK_GATE_ABSTRACT_BITS_SHIFT((uint32_t)name));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With