[CMSIS-Driver] Rationale of volatile in type of GetStatus


Whould you please help me understanding why "volatile" has been introduced since CMSIS-Driver v2.2 into the "status" type?

For instance, here : https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS/Driver/Include/Driver_I2C.h

\brief I2C Status
typedef volatile struct _ARM_I2C_STATUS {
  uint32_t busy             : 1;        ///< Busy flag
  uint32_t mode             : 1;        ///< Mode: 0=Slave, 1=Master
  uint32_t direction        : 1;        ///< Direction: 0=Transmitter, 1=Receiver
  uint32_t general_call     : 1;        ///< General Call indication (cleared on start of next Slave operation)
  uint32_t arbitration_lost : 1;        ///< Master lost arbitration (cleared on start of next Master operation)
  uint32_t bus_error        : 1;        ///< Bus error detected (cleared on start of next Master/Slave operation)
  uint32_t reserved         : 26;

Basically, ARM_I2C_STATUS (or other "status" types) are returned by GetStatus(); and, the corresponding data structure does not appear to me to be accessed directly.

Unless I am mistaken, a declaration a volatile function makes no sense as the compiler never (and could not if it wanted to) optimize functions outputs.

Defining the "status" as volatile leads to GetStatus to be declared with this qualifier.

This is not a mistake; but, it leads the compiler to complain about the declaration (gcc-arm-... -Wall -Wextra)

CMSIS_SPI.c:1361:23: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]

Would you please help me to understand the rationale of such qualifier into the type definition?

Of course, the compiler does not generate an error message but I would like to clean up the output and avoid any warning.  Is there any mean to tell the compiler this construction is acceptable?

I thank you for you help,

More questions in this forum