ArduinoCore-sam
ArduinoCore-sam copied to clipboard
Compile error with #include <unistd.h>
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.
I also need unistd.h to use close
.
Please solve this issue.
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
See pull request #91
I confirm @yanghao's patch solves the problem. Please accept the pull request.