Flag functions constexpr #2807

Open
opened 2026-01-26 15:18:47 -06:00 by michalelektryk · 0 comments
michalelektryk commented 2026-01-26 15:18:47 -06:00 (Migrated from github.com)

There are many pure functions in the SDK that could be marked as constexpr to provide more compile time computation and verification. It'd also allow for compile time allocation of internal resources. One example being pwm_gpio_to_channel and pwm_gpio_to_slice_num. If they'd be marked constexpr then following code would be valid:

constexpr int pwm_gpio = xxx;
static_assert(pwm_gpio_to_channel(pwm_gpio) == 0); // because we DMA 2B only we need it to be lower half of the register
There are many pure functions in the SDK that could be marked as constexpr to provide more compile time computation and verification. It'd also allow for compile time allocation of internal resources. One example being `pwm_gpio_to_channel` and `pwm_gpio_to_slice_num`. If they'd be marked constexpr then following code would be valid: ``` constexpr int pwm_gpio = xxx; static_assert(pwm_gpio_to_channel(pwm_gpio) == 0); // because we DMA 2B only we need it to be lower half of the register ```
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#2807
No description provided.