The link() stub for newlib in syscalls.h has the wrong type and causes a conflicts with the correct definition in unistd.h.
Here is an example sketch:
#include <unistd.h>
void setup() {
Serial.begin(9600);
Serial.println((int)sbrk(0));
}
void loop() {}
That results in this error:
D:\arduino-1.5\hardware\arduino\sam\cores\arduino/syscalls.h:43: error: declaration of C function 'int link(char*, char*)' conflicts with
D:\arduino-1.5\hardware\tools\g++_arm_none_eabi\bin../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/include/sys/unistd.h:107: error: previous declaration 'int link(const char*, const char*)' here
Changing the definition in syscalls.h to this:
extern int link(const char *cOld, const char *cNew ) ;
And the implementation in syscalls_sam3.c to this:
extern int link(const char *cOld, const char *cNew )
{
return -1 ;
}
Seems to fix the problem.