Skip to content

wrap_static_fns adds extra incorrect 'const' to pointer parameters #3251

@canton7

Description

@canton7

Hi,

I have the following static inline C function (from the ARM CMSIS):

__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority)
{
    *pPreemptPriority = ...;
    *pSubPriority = ...;
}

I'm using .wrap_static_fns(true) to generate a C wrapper for this.

However, the wrapper that's generated is:

void NVIC_DecodePriority__extern(uint32_t Priority, uint32_t PriorityGroup, const uint32_t *const pPreemptPriority, const uint32_t *const pSubPriority)
{
    NVIC_DecodePriority(Priority, PriorityGroup, pPreemptPriority, pSubPriority);
}

The pPreemptPriority and pSubPriority parameters have gained an extra const, turning them into pointer-to-const. This causes the C compiler to raise warnings.

The Rust binding however looks fine:

    #[link_name = "NVIC_DecodePriority__extern"]
    pub fn NVIC_DecodePriority(
        Priority: u32,
        PriorityGroup: u32,
        pPreemptPriority: *mut u32,
        pSubPriority: *mut u32,
    );

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions