Skip to content

Fix build warnings: guard syncword macros & fix narrowing conversions#221

Merged
Bei-Ji-Quan merged 2 commits intoHelTecAutomation:masterfrom
AbedKarmi:fix/heltec-build-warnings-20260124
Feb 3, 2026
Merged

Fix build warnings: guard syncword macros & fix narrowing conversions#221
Bei-Ji-Quan merged 2 commits intoHelTecAutomation:masterfrom
AbedKarmi:fix/heltec-build-warnings-20260124

Conversation

@AbedKarmi
Copy link
Copy Markdown
Contributor

Title: Fix build warnings: guard syncword macros & fix narrowing conversions

Summary

This patch fixes compiler warnings observed when building projects that use the Heltec ESP32 Dev-Boards library together with other radio/driver code. The changes are minimal and backwards-compatible:

  • Guard LORA_MAC_PRIVATE_SYNCWORD and LORA_MAC_PUBLIC_SYNCWORD macros with #ifndef to avoid macro redefinition warnings when different values are defined in other headers (e.g., driver headers). This reduces spurious warnings when the library is included in larger projects.

  • Add explicit casts to uint8_t in several spots in HT_st7735.cpp to avoid narrowing-conversion warnings on modern compilers with -Wnarrowing.

Why

These warnings were seen during builds and are noisy. They come from two sources:

  1. Macro redefinitions (LoRa syncwords) across multiple headers (Harmless but noisy)
  2. Narrowing conversions when initializing byte arrays from arithmetic expressions (compiler warns when moving from int to uint8_t)

Where

  • src/loramac/LoRaMac.h - wrap macro definitions in #ifndef guards
  • src/driver/sx126x.h - same guard updates
  • src/HT_st7735.cpp - add (uint8_t) casts where appropriate

Testing

  • Built LoRa-Alarm project that includes the forked Heltec library. Build shows no warnings originating from the Heltec files changed in this patch. Existing unit tests (if any) remain unaffected.

Notes

  • Changes are minimal and should be safe for the mainline library.
  • If maintainers prefer, I can instead add compiler-conditional guards or macros to keep original values for certain targets.

Suggested commit message

Fix build warnings: guard syncword macros & fix narrowing conversions

  • Add #ifndef guards around LORA_MAC_PRIVATE_SYNCWORD and LORA_MAC_PUBLIC_SYNCWORD
  • Fix narrowing conversion by casting values to uint8_t in HT_st7735.cpp

Commands to apply the patch locally and create a PR

1) Create a branch

git checkout -b fix/heltec-build-warnings

2) Apply patch (if you saved the patch file as heltec-fixes.patch in the repo root)

git apply heltec-fixes.patch

3) Commit

git add src/loramac/LoRaMac.h src/driver/sx126x.h src/HT_st7735.cpp
git commit -m "Fix build warnings: guard syncword macros & fix narrowing conversions"

4) Push to your fork and open a PR

(Assuming your fork remote is 'origin')

git push -u origin fix/heltec-build-warnings

Then open a PR on GitHub comparing fix/heltec-build-warnings to heltec master/main and paste the PR description above.

If you want, I can prepare a Git branch and push to your fork (requires your fork remote or GitHub token). Otherwise, you're ready to paste the patch and PR text in your fork's PR.

@Bei-Ji-Quan Bei-Ji-Quan merged commit 7663bf8 into HelTecAutomation:master Feb 3, 2026
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.

3 participants