Skip to content

Cannot use unistd.h #5725

Closed
Closed
@bmcdonnell-ionx

Description

@bmcdonnell-ionx

Description

  • Type: Bug
  • Priority: Major | Minor

I'm trying to use fsync() and fdatasync(), but I can't build when I #include "mbed.h" and #include <unistd.h> in my source file.


Bug

Target
LPC4088

Toolchain:
GCC_ARM

Toolchain version:

  • arm-none-eabi-c++.exe (GNU Tools for ARM Embedded Processors 6-2017-q2-update) 6.3.1 20170620 (release) [ARM/embedded-6-branch revision 249437]
  • arm-none-eabi-gcc.exe (GNU Tools for ARM Embedded Processors 6-2017-q2-update) 6.3.1 20170620 (release) [ARM/embedded-6-branch revision 249437]
  • arm-none-eabi-ld.exe GNU ld (GNU Tools for ARM Embedded Processors 6-2017-q2-update) 2.28.0.20170620
  • MCUXpresso IDE v10.1.0 [Build 589] [2017-11-14]

mbed-cli version:
1.2.2

mbed-os sha:
5f65721 (tag: mbed_lib_rev157, tag: mbed-os-5.6.6, origin/mbed-os-5.6) Merge pull request #5634 from ARMmbed/release-candidate

Expected behavior

Successful build, and fsync()/fdatasync() flushing to SD Card when I use sd-driver.

Actual behavior

Fails to build. Name collision between

unsigned _EXFUN(sleep, (unsigned int __seconds )); in unistd.h and
__INLINE static void sleep(void) in mbed_sleep.h.

Invoking: MCU C++ Compiler
arm-none-eabi-c++ -std=gnu++98 -DMBED_BUILD_TIMESTAMP=1513190426.2 -DFEATURE_LWIP=1 -D__MBED__=1 -DDEVICE_I2CSLAVE=1 -DTARGET_LIKE_MBED -DTARGET_NXP -DDEVICE_PORTINOUT=1 -DTARGET_RTOS_M4_M7 -DDEVICE_RTC=1 -DTOOLCHAIN_object -D__CMSIS_RTOS -DDEVICE_DEBUG_AWARENESS=1 -DTOOLCHAIN_GCC -DDEVICE_CAN=1 -DTARGET_CORTEX_M -DTARGET_DEBUG -DTARGET_LIKE_CORTEX_M4 -DDEVICE_ANALOGOUT=1 -DTARGET_M4 -DTARGET_UVISOR_UNSUPPORTED -DDEVICE_SERIAL=1 -DDEVICE_INTERRUPTIN=1 -DTARGET_LPCTarget -DTARGET_LPC408X -DTARGET_CORTEX -DDEVICE_I2C=1 -DDEVICE_PORTOUT=1 -D__CORTEX_M4 -DDEVICE_STDIO_MESSAGES=1 -DTARGET_MCU_LPC4088 -D__FPU_PRESENT=1 -DDEVICE_PORTIN=1 -DTARGET_LPC4088 -D__MBED_CMSIS_RTOS_CM -DDEVICE_SLEEP=1 -DTOOLCHAIN_GCC_ARM -DDEVICE_SPI=1 -DDEVICE_ETHERNET=1 -DDEVICE_SPISLAVE=1 -DDEVICE_ANALOGIN=1 -DDEVICE_PWMOUT=1 -DARM_MATH_CM4 -D__NEWLIB__ [snip]
In file included from c:\nxp\mcuxpressoide_10.1.0_589\ide\tools\arm-none-eabi\include\string.h:10:0,
                 from C:/dev/test-fat32/mbed-os/rtos/TARGET_CORTEX/rtx5/rtx_lib.h:31,
                 from C:/dev/test-fat32/mbed-os/rtos/TARGET_CORTEX/mbed_rtos_storage.h:43,
                 from C:/dev/test-fat32/mbed-os/rtos/rtos.h:28,
                 from C:/dev/test-fat32/mbed-os/mbed.h:38,
                 from ../SDCardTest.cpp:16:
c:\nxp\mcuxpressoide_10.1.0_589\ide\tools\arm-none-eabi\include\sys\unistd.h:209:10: error: conflicting declaration of C function 'unsigned int sleep(unsigned int)'
 unsigned _EXFUN(sleep, (unsigned int __seconds ));
          ^
In file included from C:/dev/test-fat32/mbed-os/drivers/PwmOut.h:24:0,
                 from C:/dev/test-fat32/mbed-os/mbed.h:80,
                 from ../SDCardTest.cpp:16:
C:/dev/test-fat32/mbed-os/platform/mbed_sleep.h:131:22: note: previous declaration 'void sleep()'
 __INLINE static void sleep(void)
                      ^~~~~
make: *** [SDCardTest.o] Error 1

Steps to reproduce

In a source file:

#include "mbed.h"
#include <unistd.h>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions