diff --git a/arch/cpu/arm/arm-def.h b/arch/cpu/arm/arm-def.h index 2cd31604c..92b19048d 100644 --- a/arch/cpu/arm/arm-def.h +++ b/arch/cpu/arm/arm-def.h @@ -60,6 +60,25 @@ typedef uint32_t uip_stats_t; typedef uint32_t rtimer_clock_t; #define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b))) /** @} */ + +/* + * The stdio.h that ships with the arm-gcc toolchain does this: + * + * int _EXFUN(putchar, (int)); + * [...] + * #define putchar(x) putc(x, stdout) + * + * This causes us a lot of trouble: For platforms using this toolchain, every + * time we use putchar we need to first #undef putchar. What we do here is to + * #undef putchar across the board. The resulting code will cause the linker + * to search for a symbol named putchar and this allows us to use the + * implementation under os/lib/dbg-io. + * + * This will fail if stdio.h is included before contiki.h, but it is common + * practice to include contiki.h first + */ +#include +#undef putchar /*---------------------------------------------------------------------------*/ #endif /* ARM_DEF_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/cc2538/dbg.c b/arch/cpu/cc2538/dbg.c index c39e05af7..7b33bc471 100644 --- a/arch/cpu/cc2538/dbg.c +++ b/arch/cpu/cc2538/dbg.c @@ -48,9 +48,6 @@ #define flush() #endif /*---------------------------------------------------------------------------*/ -#undef putchar -#undef puts - #define SLIP_END 0300 /*---------------------------------------------------------------------------*/ int diff --git a/os/lib/dbg-io/putchar.c b/os/lib/dbg-io/putchar.c index 11bb7b5e6..d5b81e2ab 100644 --- a/os/lib/dbg-io/putchar.c +++ b/os/lib/dbg-io/putchar.c @@ -35,7 +35,6 @@ #include #include /*---------------------------------------------------------------------------*/ -#undef putchar #undef putc /*---------------------------------------------------------------------------*/ int