Skip to content

Fix ambiguous irDebugPrint calls when DEBUG is on - #5

Merged
jorgecis merged 1 commit into
mainfrom
fix/debug-print-overloads
Oct 10, 2026
Merged

jorgecis merged 1 commit into
mainfrom
fix/debug-print-overloads

Conversation

@jorgecis

Copy link
Copy Markdown
Owner

Fixes #4.

Problem

With DEBUG defined (e.g. -DDEBUG from a PlatformIO debug env), the library failed to compile:

IRplatform.h:107:17: error: call of overloaded 'irDebugPrint(int)' is ambiguous

irDebugPrint only had uint64_t and int64_t overloads, and an int, uint16_t, uint32_t or pointer difference converts equally well to both. It hits DPRINT calls in IRrecv.cpp, ir_Corona.cpp, ir_Lutron.cpp and others.

CI did not catch it because CONFIG_IRREMOTE_DEBUG never actually enabled debug output: IRremoteESP8266.h includes IRplatform.h (which tests DEBUG) before IRconfig.h (which defines DEBUG from Kconfig). The "Debug tracing" CI step was building with DPRINT compiled out.

Fix

  • A template irDebugPrint overload for any other integral type forwards to the int64_t / uint64_t overload by signedness. The exact-match non-template overloads still win for their own types.
  • New irDebugPrint(char), so a char prints as a character rather than a number.
  • IRplatform.h includes IRconfig.h before the DEBUG test, so CONFIG_IRREMOTE_DEBUG=y works. The existing CI debug step now really compiles the debug path.

Testing

  • Reproduced the reported errors building ir_receive_dump for esp32 on IDF 5.5 with -DDEBUG.
  • After the fix, that build and one with CONFIG_IRREMOTE_DEBUG=y both complete with no errors or warnings, and the ELF contains irDebugPrint (so debug code is really compiled in).
  • Host unit tests pass; cpplint --recursive src include is clean.

DPRINT() of an int, uint16_t, uint32_t or a pointer difference converted
equally well to the uint64_t and int64_t overloads, so any build with
DEBUG defined failed to compile. Route every other integer type through
a template that picks the signed or unsigned overload, and print a char
as a character.

CONFIG_IRREMOTE_DEBUG never reached DPRINT either: IRconfig.h, which
maps it to DEBUG, was included after IRplatform.h had already tested
DEBUG. That is why the CI debug build passed. Include IRconfig.h from
IRplatform.h before the test.

Fixes #4
@jorgecis jorgecis mentioned this pull request Oct 10, 2026
@jorgecis
jorgecis merged commit 3cbab6d into main Oct 10, 2026
57 checks passed
@jorgecis jorgecis mentioned this pull request Oct 11, 2026
@jorgecis
jorgecis deleted the fix/debug-print-overloads branch October 12, 2026 02:49
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.

Compile errors

1 participant