Conflicting types in SEGGER_RTT_Syscalls_GCC.c

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Conflicting types in SEGGER_RTT_Syscalls_GCC.c

    Hi,

    this is unlikely a problem of RTT, but some of you might have an idea whats wrong here?


    ../../libs/middleware/segger_rtt/Syscalls/SEGGER_RTT_Syscalls_GCC.c:104:5: error: conflicting types for '_write_r'

    int _write_r(struct _reent *r, int file, const void *ptr, int len) {
    ^
    In file included from ../../libs/middleware/segger_rtt/Syscalls/SEGGER_RTT_Syscalls_GCC.c:46:0:
    /usr/local/arm-none-eabi/include/reent.h:159:17: note: previous declaration of '_write_r' was here
    extern _ssize_t _write_r _PARAMS ((struct _reent *, int, const void *, size_t));


    it seems for me that my size_t != int. is this correct ?

    any idea on how to fix this problem?

    The post was edited 2 times, last by pruesch ().

  • okay, the signature of the std lib _write_r function is:

    C Source Code

    1. extern _ssize_t _write_r _PARAMS ((struct _reent *, int, const void *, size_t));


    vs. the signature of the SEGGER_RTT_Syscalls_GCC.c

    C Source Code

    1. int _write_r(struct _reent *r, int file, const void *ptr, int len);


    boils down to this difference:

    size_t is an unsigned type, int is signed.


    I'm a bit curious why I face this problem and can't find anyone else with this problem.

    we are using newlib.
  • Followup problem

    I am able to get through the problem by fixing the prototype to match others (don't know why it is a problem though).

    However, it now fails link:

    Source Code

    1. Building target: simple.elf
    2. Invoking: Cross ARM C++ Linker
    3. arm-none-eabi-g++ -mcpu=cortex-m0plus -mthumb -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -flto -g3 -T "../MKL17Z128xxx4_flash.ld" -Xlinker --gc-sections -Wl,-Map,"simple.map" --specs=nano.specs -specs=nosys.specs -Xlinker -z -Xlinker muldefs -o "simple.elf" ./utilities/fsl_debug_console.o ./utilities/fsl_notifier.o ./utilities/fsl_sbrk.o ./utilities/fsl_shell.o ./startup/startup_MKL17Z4.o ./startup/system_MKL17Z4.o ./source/gpio.o ./source/i2c.o ./source/ilxmic.o ./source/led.o ./source/main.o ./source/rtt.o ./source/util.o ./drivers/fsl_adc16.o ./drivers/fsl_clock.o ./drivers/fsl_cmp.o ./drivers/fsl_common.o ./drivers/fsl_cop.o ./drivers/fsl_dac.o ./drivers/fsl_dma.o ./drivers/fsl_dmamux.o ./drivers/fsl_flash.o ./drivers/fsl_flexio.o ./drivers/fsl_flexio_i2c_master.o ./drivers/fsl_flexio_i2s.o ./drivers/fsl_flexio_i2s_dma.o ./drivers/fsl_flexio_spi.o ./drivers/fsl_flexio_spi_dma.o ./drivers/fsl_flexio_uart.o ./drivers/fsl_flexio_uart_dma.o ./drivers/fsl_gpio.o ./drivers/fsl_i2c.o ./drivers/fsl_i2c_dma.o ./drivers/fsl_llwu.o ./drivers/fsl_lptmr.o ./drivers/fsl_lpuart.o ./drivers/fsl_lpuart_dma.o ./drivers/fsl_pit.o ./drivers/fsl_pmc.o ./drivers/fsl_rcm.o ./drivers/fsl_rtc.o ./drivers/fsl_sai.o ./drivers/fsl_sai_dma.o ./drivers/fsl_sim.o ./drivers/fsl_smc.o ./drivers/fsl_spi.o ./drivers/fsl_spi_dma.o ./drivers/fsl_tpm.o ./drivers/fsl_uart.o ./drivers/fsl_uart_dma.o ./drivers/fsl_vref.o ./board/board.o ./board/clock_config.o ./board/pin_mux.o ./RTT/Syscalls/SEGGER_RTT_Syscalls_GCC.o ./RTT/RTT/SEGGER_RTT.o ./RTT/RTT/SEGGER_RTT_printf.o
    4. `_write_r' referenced in section `.text.__swrite' of c:/freescale/kds_v3/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv6-m\libg_s.a(lib_a-stdio.o): defined in discarded section `.text' of ./RTT/Syscalls/SEGGER_RTT_Syscalls_GCC.o (symbol from plugin)
    5. `_read' referenced in section `.text._read_r' of c:/freescale/kds_v3/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv6-m\libg_s.a(lib_a-readr.o): defined in discarded section `.text' of ./utilities/fsl_debug_console.o (symbol from plugin)
    6. collect2.exe: error: ld returned 1 exit status
    7. makefile:63: recipe for target 'simple.elf' failed
    8. make: *** [simple.elf] Error 1


    I cannot figure out if there is a way to remove the SDK version of _write_r or why this is a problem at all. At the very least, I want it to ignore the system's _write_r and not the SEGGER.

    - Peter