Skip to content

build, silence -Wattributes for the h5:: reflection attribute namespace #291

@steven-varga

Description

@steven-varga

Symptom

5 -Wattributes warnings when compiling any TU that includes a struct annotated with the h5cpp-compiler reflection attributes (e.g. examples/compound/non-pod.h, pulled in by test_compound_struct_io.cpp):

warning: 'h5::doc' scoped attribute directive ignored [-Wattributes]
warning: 'h5::chunk' scoped attribute directive ignored [-Wattributes]
warning: 'h5::compress' scoped attribute directive ignored [-Wattributes]
warning: 'h5::name' scoped attribute directive ignored [-Wattributes]
warning: 'h5::ignore' scoped attribute directive ignored [-Wattributes]

Cause

[[h5::doc(...)]], [[h5::chunk(N)]], [[h5::compress(...)]], [[h5::name(...)]], [[h5::ignore]] are h5cpp-compiler reflection annotations. A plain compiler (no h5cpp-compiler pass) doesn't know the h5:: attribute namespace, so it ignores them and warns. This is expected — but noisy, and it hits downstream users who annotate their own structs, not just our examples/tests.

Fix

Declare the h5:: attribute namespace intentional on the h5cpp INTERFACE target so the suppression propagates to every consumer (examples, example-derived tests, and downstream projects), guarded per compiler:

  • GCC 11+: -Wno-attributes=h5:: (namespace-scoped — hides nothing else)
  • Clang / older GCC: -Wno-unknown-attributes (fallback)
  • MSVC: /wd5030

Use check_cxx_compiler_flag so unsupported compilers don't break.

Acceptance

  • Zero -Wattributes / unknown-attribute warnings for h5:: annotations across the test + examples build on the CI matrix.
  • No other warnings suppressed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions