Skip to content

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

Description

@iLoveAndyBaker

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions