C standard (for the Flex-CAN driver)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

C standard (for the Flex-CAN driver)

673 次查看
scotty
Contributor IV

Hello SDK developers,

Thank you for software support. We use the FLEX-CAN driver which can be found at

https://github.com/nxp-mcuxpresso/mcux-sdk/blob/main/drivers/flexcan/fsl_flexcan.c

https://github.com/nxp-mcuxpresso/mcux-sdk/blob/main/drivers/flexcan/fsl_flexcan.h

Currently we compile our project with the C99 or GNU99 standard.

When we compile this driver, a lot of warnings are issued by the GNU compiler. (With the C2x standard, the warnings are gone.)

Please can you specify the C standard to which the SDK drivers are compliant. Thank you.

0 项奖励
回复
3 回复数

615 次查看
scotty
Contributor IV

Thank you, Alice, for you response.

Yes, indeed. When compiling with the C99 standard we get 52 warnings. But the number of different warnings is less:

  • warning: ISO C restricts enumerator values to range of 'int' before C2X [-Wpedantic]
  • warning: ISO C99 doesn't support unnamed structs/unions [-Wpedantic]
  • warning: union has no named members [-Wpedantic]
  • warning: struct has no named members [-Wpedantic]
  • warning: conversion from 'unsigned int' to 'uint16_t' {aka 'short unsigned int'} may change value [-Wconversion]
  • warning: conversion from 'int' to 'unsigned char:1' may change value [-Wconversion]

Maybe you want to specify from which FSL version which coding standard is required. Thanks.

0 项奖励
回复

668 次查看
scotty
Contributor IV

In MCUXpresso SDK fact sheet it says that "All drivers and startup code are MISRA-C:2012 compliant". - I wonder if this is correct.

0 项奖励
回复

626 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @scotty 

The SDK drivers are primarily written to be compliant with the C99 standard. 

The fact that the warnings disappear when using the C2x standard suggests that some constructs in the SDK drivers are more aligned with newer C standards or that the GNU compiler is more lenient in C2x mode.

 

BR

Alice

 

 

0 项奖励
回复