STMicroelectronics / STM32CubeF2

STM32Cube MCU Full Package for the STM32F2 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
43 stars 25 forks source link

const #16

Closed RetoFx closed 1 month ago

RetoFx commented 1 month ago

You add more and more const to your cube code. This is great. const is one of the most important keywords in C.

For example

HAL_StatusTypeDef HAL_DCMI_ConfigSyncUnmask(DCMI_HandleTypeDef hdcmi, const DCMI_SyncUnmaskTypeDef SyncUnmask);

But you add const before the type. We and lot of other developer prefer, that const is after the type. This simplify the code understanding as soon as there is also a pointer.

the explanation is:

It helps me keep track of 'what' is constant by reading the type declaration from right to left:

Type * const obj;        // read right-to-left:  const pointer to Object
Type const * obj;        // read right-to-left:  pointer to const Object
Type const * const obj;  // read right-to-left:  const pointer to const Object

So please improve this asap

ALABSTM commented 1 month ago

Hi @RetoFx,

Thank you for the suggestion. However, as both notations, const Type * obj and Type const * obj, are the same, we prefer keeping the first one. Thank you again for your suggestion.

With regards,