Flag functions constexpr

Open
#2,807 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
c
Domain
embedded-iot

Research direction

Start by locating the SDK implementations and declarations of pwm_gpio_to_channel and pwm_gpio_to_slice_num, then identify other pure functions that could support compile-time evaluation. Verify that the shown constexpr and static_assert usage compiles, and that the selected functions provide the intended compile-time results.

Written by the indexing model from the issue text.

Description

c++ enhancement

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
Dominant language
C
Stars
5k
Forks
1.3k
Avg merge
2d 17h
Merged PRs (30d)
17

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from raspberrypi/pico-sdk

All issues in raspberrypi/pico-sdk

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.