Open ghost opened 3 years ago
Thanks - do you know the exact version it needs to be adjusted or have a link with further info on the version with the change? Adjusting that fails to compile on sdcc 3.4.0 so would like some ifdefs to support both.
The change of putchar() prototype was made in version 3.7.0
SDCC 3.7.0 Feature List:
It was a fix of an issue from 2016-06-16 (SDCC changelog):
Cool, it will now check version of sdcc to decide what to do. Hopefully that resolves it!
I'm not sure that actually fixed it at least not for me under Windows/Linux with SDCC 4.0.0 I will start by saying I don't know wtf I'm doing but.... Shouldn't
also both in display C and H, the declaration and use of putchar() needs to be fixed for >3.7. With the code above the Int/Int that is expected turns to int/char with the current code. Adding PUTCHAR_TYPE2 fixes that. But I'm not a fan of that name.
display.h
// sdcc 3.7.0+ uses int putchar
#if (__SDCC_VERSION_MAGOR == 3 && __SDCC_VERSION_MINOR >= 7) || (__SDCC_VERSION_MAJOR >= 4)
#define PUTCHAR_INT
#define PUTCHAR_TYPE int
#define PUTCHAR_TYPE2 int
#else
#define PUTCHAR_TYPE void
#define PUTCHAR_TYPE2 char
#endif
display.h
#ifndef LOCAL
PUTCHAR_TYPE putchar(PUTCHAR_TYPE2 c);
#endif
display.c
/* sdcc provides printf if we provide this */
PUTCHAR_TYPE putchar(PUTCHAR_TYPE2 c)
{
#ifdef SIMULATOR
while (!TI); /* wait end of last transmission */
TI = 0;
SBUF = c; /* transmit to serial */
#else
u8 i;
c &= 0x7f;
if (c >= FONT_OFFSET)
{
for (i = 0; i < FONT_WIDTH; i++)
txData(font[c - FONT_OFFSET][i] ^ (reverseTxt ? 0xff : 0));
txData(reverseTxt ? 0xff : 0x00);
}
#endif
#ifdef PUTCHAR_INT
return c;
#endif
}
When you want to compile the source without error, with a version of SDCC > 3.6.0, you need to change the putchar() function prototype to fit SDCC, bacause it was changed. I tested it on SDCC v4.0 (Linux Fedora 33).
In display.h
and in display.c