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.
Symptom
5
-Wattributeswarnings when compiling any TU that includes a struct annotated with the h5cpp-compiler reflection attributes (e.g.examples/compound/non-pod.h, pulled in bytest_compound_struct_io.cpp):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 theh5::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 theh5cppINTERFACE target so the suppression propagates to every consumer (examples, example-derived tests, and downstream projects), guarded per compiler:-Wno-attributes=h5::(namespace-scoped — hides nothing else)-Wno-unknown-attributes(fallback)/wd5030Use
check_cxx_compiler_flagso unsupported compilers don't break.Acceptance
-Wattributes/ unknown-attribute warnings forh5::annotations across the test + examples build on the CI matrix.