Cannot perform static_assert in C++ on header files generated by pioasm #2650

Closed
opened 2025-09-06 09:24:11 -05:00 by rhulme · 1 comment
rhulme commented 2025-09-06 09:24:11 -05:00 (Migrated from github.com)

Because the pio_program structure is not declared constexpr, it's not possible to perform compile-time checks on the contents.

In my project, I have a couple of PIO programs that I would like to ensure both fit in a single PIO instance (i.e. in the 32-word memory) and discover at compile-time if changes are made that would prevent this, rather than with a panic at run-time.

Obviously, constexpr is a C++ keyword so can't be used if the header file is included from a plain C file, but the keyword to use can be determined via checking whether __cplusplus is defined.

Because the ```pio_program``` structure is not declared ```constexpr```, it's not possible to perform compile-time checks on the contents. In my project, I have a couple of PIO programs that I would like to ensure both fit in a single PIO instance (i.e. in the 32-word memory) and discover at compile-time if changes are made that would prevent this, rather than with a panic at run-time. Obviously, ```constexpr``` is a C++ keyword so can't be used if the header file is included from a plain C file, but the keyword to use can be determined via checking whether ```__cplusplus``` is defined.
lurch commented 2026-03-02 18:27:24 -06:00 (Migrated from github.com)

Linked PR has been merged into develop

Linked PR has been merged into `develop`
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#2650
No description provided.