I have been working on stabilising our out-of-tree sources following the upgrade to the v5.0 Final Release, and came across an incompatibility between the ‘<stdio.h>’ provided with Newlib v2.5.0 and the one provided with LibC++ v5.0.
The problem is how LibC++ handles the ‘getc’ and ‘putc’ implementations, and if these are defined it uses a shim, then ‘#undef’s the original, and redefines them as functions.
In general this is a good strategy, but in this case ‘getc’ and ‘putc’ are both declared as external functions, and subsequently defined as macros. When LibC++ undefines these macros and defines the functions ‘getc’ and ‘putc’, it does so appending ‘_NOEXCEPT’ and this causes a multiple definition conflict with the declaration in Newlib’s ‘<stdio.h>’ which does not have this appended.
My workaround was to rewrite these as:
#ifndef NEWLIB
int getc(FILE *__lcpp_x) _NOEXCEPT {
#else
int getc(FILE *__lcpp_x)
#endif
and:
#ifndef NEWLIB
int petc(int __lcpp_x, FILE *__lcpp_y) _NOEXCEPT {
#else
int petc(int __lcpp_x, FILE *__lcpp_y)
#endif
All the best,
MartinO