Skip to content

BUILD_ASSURE causes warning #13

@c-mauderer

Description

@c-mauderer

Hello,

the BUILD_ASSURE in the fsl_dcp.c can cause a compiler warning:

mcux-sdk/drivers/dcp/fsl_dcp.c

That problem appeared when the library is compiled in the context of RTEMS:

https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5300#note_126673

The exact warning is:

../../../bsps/arm/imxrt/mcux-sdk/drivers/dcp/fsl_dcp.c: In function 'DCP_HASH_Init':
../../../bsps/arm/imxrt/mcux-sdk/drivers/dcp/fsl_dcp.c:1214:77: warning: nested extern declaration of 'dcp_hash_ctx_t_size' [-Wnested-externs]
 1214 |     BUILD_ASSURE(sizeof(dcp_hash_ctx_t) >= sizeof(dcp_hash_ctx_internal_t), dcp_hash_ctx_t_size);
      |                                                                             ^~~~~~~~~~~~~~~~~~~
../../../bsps/arm/imxrt/mcux-sdk/drivers/dcp/fsl_dcp.c:24:49: note: in definition of macro 'BUILD_ASSURE'
   24 | #define BUILD_ASSURE(condition, msg) extern int msg[1 - 2 * (!(condition))] __attribute__((unused))
      |                        

The version that is used in RTEMS is a bit older. But the line didn't change and the warning would still be the same.

I would suggest to use a C11 _Static_assert instead of the custom BUILD_ASSURE.

With kind regards

Christian Mauderer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions