util: make STATIC_ASSERT usable at file scope #1952

pull real-or-random wants to merge 2 commits into bitcoin-core:master from real-or-random:worktree-better-static-assert changing 3 files +55 −63
  1. real-or-random commented at 3:41 PM on October 1, 2026: contributor

    Replace the switch-based STATIC_ASSERT, which is a statement and thus only usable inside functions, with a declaration-like macro. It uses _Static_assert in C11 mode and, as an extension, with GCC >= 4.6 and Clang in pre-C11 modes. Other compilers fall back to declaring an extern array whose size is negative if the assertion fails.

    Since STATIC_ASSERT now expands to a declaration, move its use in secp256k1_ge_impl_to_bytes before VERIFY_CHECK to avoid mixing declarations and code, which C89 forbids.

  2. util: make STATIC_ASSERT usable at file scope
    Replace the switch-based STATIC_ASSERT, which is a statement and thus
    only usable inside functions, with a declaration-like macro. It uses
    _Static_assert in C11 mode and, as an extension, with GCC >= 4.6 and
    Clang in pre-C11 modes. Other compilers fall back to declaring an
    extern array whose size is negative if the assertion fails.
    
    Since STATIC_ASSERT now expands to a declaration, move its use in
    secp256k1_ge_impl_to_bytes before VERIFY_CHECK to avoid mixing
    declarations and code, which C89 forbids.
    7d53109b85
  3. real-or-random added the label tweak/refactor on Oct 1, 2026
  4. real-or-random added the label meta/development on Oct 1, 2026
  5. assumptions: move static assertions to file scope
    Now that STATIC_ASSERT can be used at file scope, the
    secp256k1_assumption_checker function, which existed only to provide a
    function context for the assertions, is no longer needed.
    20fcbae219
  6. theStack commented at 5:10 PM on October 2, 2026: contributor

    Concept ACK


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-10-03 05:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me