Skip to content

Compile error with #include <unistd.h> #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
yoursunny opened this issue Nov 19, 2018 · 4 comments
Open

Compile error with #include <unistd.h> #63

yoursunny opened this issue Nov 19, 2018 · 4 comments

Comments

@yoursunny
Copy link

IDE: Arduino 1.8.7 on Windows.
Core version: Arduino SAM Boards 1.6.11, installed from Boards Manager

MCVE sketch:

#include <unistd.h>

void setup() {
}

void loop() {
}

Error message:

Arduino: 1.8.7 (Windows Store 1.8.15.0) (Windows 10), Board: "Arduino Due (Programming Port)"
In file included from c:\users\sunny\documents\arduinodata\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\stdlib.h:11:0,
                 from C:\Users\sunny\Documents\ArduinoData\packages\arduino\hardware\sam\1.6.11\cores\arduino/Arduino.h:24,
                 from sketch\sketch_nov18a.ino.cpp:1:
c:\users\sunny\documents\arduinodata\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\sys\unistd.h:118:9: error: declaration of C function 'int link(const char*, const char*)' conflicts with
 int     _EXFUN(link, (const char *__path1, const char *__path2 ));
         ^
In file included from C:\Users\sunny\Documents\ArduinoData\packages\arduino\hardware\sam\1.6.11\variants\arduino_due_x/variant.h:50:0,
                 from C:\Users\sunny\Documents\ArduinoData\packages\arduino\hardware\sam\1.6.11\cores\arduino/Arduino.h:201,
                 from sketch\sketch_nov18a.ino.cpp:1:
C:\Users\sunny\Documents\ArduinoData\packages\arduino\hardware\sam\1.6.11\cores\arduino/syscalls.h:43:12: error: previous declaration 'int link(char*, char*)' here
 extern int link( char *cOld, char *cNew ) ;
            ^
exit status 1
Error compiling for board Arduino Due (Programming Port).

The header unistd.h is used by ArduinoCbor library in cn-cbor.h.

@mrubioroy
Copy link

I also need unistd.h to use close.
Please solve this issue.

@yanghao
Copy link

yanghao commented Oct 4, 2019

I had the same issue and here is how I fixed it ... since "link()" is not actually used nor implemented, I think by making the prototype declaration consistent will simply solve the issue. There are two files to modify:

.arduino15/packages/arduino/hardware/sam/1.6.12/cores/arduino/syscalls_sam3.c
.arduino15/packages/arduino/hardware/sam/1.6.12/cores/arduino/syscalls.h

In both files just add the "const" keyword to the "link()" declaration and all works now.

Original error messages:

_____CXX build/configs/arduino_due/test/firmware/arduino/due/main.o In file included from /home/yanghao/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/include/stdlib.h:11:0, from /home/yanghao/.arduino15/packages/arduino/hardware/sam/1.6.12/cores/arduino/Arduino.h:24, from firmware/arduino/due/main.cpp:1: /home/yanghao/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/include/sys/unistd.h:118:9: error: declaration of C function 'int link(const char*, const char*)' conflicts with int _EXFUN(link, (const char *__path1, const char *__path2 )); ^ In file included from /home/yanghao/.arduino15/packages/arduino/hardware/sam/1.6.12/variants/arduino_due_x/variant.h:50:0, from /home/yanghao/.arduino15/packages/arduino/hardware/sam/1.6.12/cores/arduino/Arduino.h:201, from firmware/arduino/due/main.cpp:1: /home/yanghao/.arduino15/packages/arduino/hardware/sam/1.6.12/cores/arduino/syscalls.h:43:12: error: previous declaration 'int link(char*, char*)' here extern int link( char *cOld, char *cNew ) ; ^ scons: *** [build/configs/arduino_due/test/firmware/arduino/due/main.o] Error 1

And:

/home/yanghao/.arduino15/packages/arduino/hardware/sam/1.6.12/cores/arduino/syscalls_sam3.c:80:12: error: conflicting types for 'link' extern int link( UNUSED(char *cOld), UNUSED(char *cNew) ) ^ In file included from /home/yanghao/.arduino15/packages/arduino/hardware/sam/1.6.12/cores/arduino/syscalls_sam3.c:31:0: /home/yanghao/.arduino15/packages/arduino/hardware/sam/1.6.12/cores/arduino/syscalls.h:43:12: note: previous declaration of 'link' was here extern int link( const char *cOld, const char *cNew ) ; ^ scons: *** [build/configs/arduino_due/test/firmware/external/arduino/due/cores/arduino/syscalls_sam3.c.o] Error 1

@yanghao
Copy link

yanghao commented Oct 4, 2019

See pull request #91

@mrubioroy
Copy link

I confirm @yanghao's patch solves the problem. Please accept the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants