mcurses icon indicating copy to clipboard operation
mcurses copied to clipboard

RP2040 compile error: setFunction_putchar pointer type mismatch (uint_fast8_t vs uint8_t) — plus initscr() never initializes

Open iLoveAndyBaker opened this issue 3 months ago • 0 comments

On RP2040 (Arduino), compiling fails due to a function-pointer type mismatch in mcurses.c. The file declares FunctionPointer_putchar as void ()(uint_fast8_t), but the public API (mcurses.h) and typical Arduino callbacks use void ()(uint8_t). This causes an incompatible pointer types error when calling setFunction_putchar().

Compiler error (excerpt): assignment to 'void ()(uint_fast8_t)' from incompatible pointer type 'void ()(uint8_t)' [-Wincompatible-pointer-types]

Repro:

Board: RP2040 (e.g., Pico, KB2040) Arduino IDE 2.x Sketch calls:

setFunction_putchar(Arduino_putchar) where Arduino_putchar(uint8_t c) { Serial.write(c); }

Expected: Library compiles on RP2040.

initscr() initializes and emits ANSI to the configured output channel.

Actual: Build fails with the pointer type mismatch.

Additionally, initscr() returns ERR because mcurses_phyio_init() returns 0 (false), so initialization never proceeds.

Proposed fixes:

In mcurses.c, change the function pointer to match the header/API:

from: void (*FunctionPointer_putchar)(uint_fast8_t ch);

to: void (*FunctionPointer_putchar)(uint8_t ch);

In mcurses.c, make mcurses_phyio_init() indicate success so initscr() runs:

return TRUE instead of 0.

Notes:

After these two small changes, the library compiles and initializes correctly on RP2040.

Optional: there’s a minor parameter-name typo (functionPoitner) in both files; not functional, just cosmetic.

iLoveAndyBaker avatar Oct 20 '25 19:10 iLoveAndyBaker