Skip to content

Use _Static_assert instead of static_assert for gnu99 toolchains - #2

Merged
NathanBelza merged 3 commits into
mainfrom
fix/gnu99-static-assert
Aug 1, 2026
Merged

Use _Static_assert instead of static_assert for gnu99 toolchains#2
NathanBelza merged 3 commits into
mainfrom
fix/gnu99-static-assert

Conversation

@NWarren42

Copy link
Copy Markdown
Contributor

Boards building this library's C source directly under Arduino-ESP32's PlatformIO framework compile with -std=gnu99, where <assert.h> doesn't define the static_assert convenience macro (it's gated on STDC_VERSION >= 201112L). _Static_assert is the underlying GCC/Clang keyword and is available as an extension in every C dialect, so this avoids needing a per-project build-flag workaround on every consuming board.

Boards building this library's C source directly under Arduino-ESP32's
PlatformIO framework compile with -std=gnu99, where <assert.h> doesn't
define the static_assert convenience macro (it's gated on
__STDC_VERSION__ >= 201112L). _Static_assert is the underlying GCC/Clang
keyword and is available as an extension in every C dialect, so this
avoids needing a per-project build-flag workaround on every consuming
board.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves C build compatibility for environments that compile the library under -std=gnu99 (notably Arduino-ESP32 + PlatformIO), where <assert.h> may not provide the static_assert convenience macro. It switches the compile-time checks to use _Static_assert, avoiding a consumer-side build-flag workaround.

Changes:

  • Replace static_assert(...) usages with _Static_assert(...) in the core C implementation.
  • Preserve the existing compile-time size/protocol invariants (magic number length, 32-bit float assumption).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ari-kl
ari-kl previously approved these changes Jul 21, 2026
@NathanBelza
NathanBelza merged commit 3f37353 into main Aug 1, 2026
2 checks passed
@NathanBelza
NathanBelza deleted the fix/gnu99-static-assert branch August 1, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants