Skip to content

[lightning-ln882h] Fix -Wregister warnings from CmBacktrace cmb_def.h#376

Open
Bl00d-B0b wants to merge 1 commit intolibretiny-eu:masterfrom
Bl00d-B0b:fix/ln882h-cmb-register-keyword
Open

[lightning-ln882h] Fix -Wregister warnings from CmBacktrace cmb_def.h#376
Bl00d-B0b wants to merge 1 commit intolibretiny-eu:masterfrom
Bl00d-B0b:fix/ln882h-cmb-register-keyword

Conversation

@Bl00d-B0b
Copy link
Copy Markdown

@Bl00d-B0b Bl00d-B0b commented Apr 2, 2026

The LN882H SDK CmBacktrace library (cmb_def.h) uses the register storage class specifier in three inline assembly helpers: cmb_get_msp(), cmb_get_psp(), and cmb_get_sp().

This keyword was removed in C++17 (P0001R1), producing spurious -Wregister warnings during every build when compiled with -std=c++17 (as ESPHome does):

cmb_def.h:408:27: warning: ISO C++17 does not allow register storage class specifier [-Wregister]
  408 |         register uint32_t result;

The warning appears 9 times per build (3 inline functions x 3 translation units that include the header).

Fix: Add -Wno-register to CXXFLAGS in builder/family/lightning-ln882h.py. This is a no-op for plain LibreTiny builds (which do not use C++17) and only suppresses the warning for C++ consumers such as ESPHome.

No SDK sources are modified.

Bl00d-B0b pushed a commit to Bl00d-B0b/libretiny that referenced this pull request Apr 2, 2026
…libretiny-eu#376)

The LN882H SDK's CmBacktrace library (cmb_def.h) uses the 'register'
storage class specifier in inline assembly helpers (cmb_get_msp/psp/sp).
This keyword was removed in C++17 (P0001R1) and produces -Wregister
warnings when compiling with -std=c++17.

Add a fixup header that wraps the original cmb_def.h with GCC diagnostic
pragmas to suppress the warning without modifying SDK sources.
Bl00d-B0b pushed a commit to Bl00d-B0b/libretiny that referenced this pull request Apr 2, 2026
…libretiny-eu#376)

The LN882H SDK's CmBacktrace library (cmb_def.h) uses the 'register'
storage class specifier in inline assembly helpers (cmb_get_msp/psp/sp).
This keyword was removed in C++17 (P0001R1) and produces -Wregister
warnings when compiling with -std=c++17.

Add a fixup header that wraps the original cmb_def.h with GCC diagnostic
pragmas to suppress the warning without modifying SDK sources.
Bl00d-B0b pushed a commit to Bl00d-B0b/libretiny that referenced this pull request Apr 2, 2026
…libretiny-eu#376)

The LN882H SDK's CmBacktrace library (cmb_def.h) uses the 'register'
storage class specifier in inline assembly helpers (cmb_get_msp/psp/sp).
This keyword was removed in C++17 (P0001R1) and produces -Wregister
warnings when compiling with -std=c++17.

Add a fixup header that wraps the original cmb_def.h with GCC diagnostic
pragmas to suppress the warning without modifying SDK sources.
@Bl00d-B0b Bl00d-B0b force-pushed the fix/ln882h-cmb-register-keyword branch from 0bee8a3 to 74cfab2 Compare April 2, 2026 19:51
Bl00d-B0b pushed a commit to Bl00d-B0b/libretiny that referenced this pull request Apr 2, 2026
…libretiny-eu#376)

The LN882H SDK's CmBacktrace library (cmb_def.h) uses the 'register'
storage class specifier in inline assembly helpers (cmb_get_msp/psp/sp).
This keyword was removed in C++17 (P0001R1) and produces -Wregister
warnings when compiling with -std=c++17.

Add a fixup header that wraps the original cmb_def.h with GCC diagnostic
pragmas to suppress the warning without modifying SDK sources.
@kuba2k2
Copy link
Copy Markdown
Member

kuba2k2 commented Apr 3, 2026

Why not just add -Wno-register to GCC compile flags for the entire build?

Side note, LibreTiny doesn't use C++17 by default; ESPHome does.

@Bl00d-B0b
Copy link
Copy Markdown
Author

Agreed, -Wno-register is simpler and cleaner. Happy to rework the PR to use that instead — would just need to revert the sdk_private.h change and add the flag in the right place.

Which build file should it go in? I am thinking somewhere in the lightning-ln882h platform build environment (e.g. a SConscript or platform builder), but I am not familiar enough with the LibreTiny build system to know the canonical location for per-platform compiler flags.

@kuba2k2
Copy link
Copy Markdown
Member

kuba2k2 commented Apr 5, 2026

The most logical place to add it would be the file where all other options are defined, builder/family/lightning-ln882h.py. Note that this warning only concerns C++ code, so it should go to the CXXFLAGS variable, instead of the CFLAGS.

…libretiny-eu#376)

cmb_def.h uses the 'register' storage class specifier (removed in C++17)
in cmb_get_msp/psp/sp(), producing 9 spurious -Wregister warnings per build
when compiled with -std=c++17 (as ESPHome does).

Add -Wno-register to CXXFLAGS to suppress the warning for C++ builds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Bl00d-B0b Bl00d-B0b force-pushed the fix/ln882h-cmb-register-keyword branch from 74cfab2 to c0c546e Compare April 7, 2026 05:33
Bl00d-B0b pushed a commit to Bl00d-B0b/libretiny that referenced this pull request Apr 7, 2026
…libretiny-eu#376)

cmb_def.h uses the 'register' storage class specifier (removed in C++17)
in cmb_get_msp/psp/sp(), producing 9 spurious -Wregister warnings per build
when compiled with -std=c++17 (as ESPHome does).

Add -Wno-register to CXXFLAGS to suppress the warning for C++ builds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Bl00d-B0b
Copy link
Copy Markdown
Author

Done — reworked the PR to use -Wno-register in CXXFLAGS in builder/family/lightning-ln882h.py as you suggested, and the sdk_private.h pragma change has been reverted.

@kuba2k2 kuba2k2 added quality Code quality or safety improvements LN882H Lightning LN882H family labels Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LN882H Lightning LN882H family quality Code quality or safety improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants