Go Down

Topic: Incorrect type for link() in syscalls.h prevents use of unistd.h (Read 817 times) previous topic - next topic

fat16lib

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:

Code: [Select]

#include <unistd.h>
void setup() {
  Serial.begin(9600);
  Serial.println((int)sbrk(0));
}
void loop() {}


That results in this error:
Quote

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:
Code: [Select]

extern int link(const  char *cOld, const char *cNew ) ;


And the implementation in syscalls_sam3.c to this:
Code: [Select]

extern int link(const char *cOld, const char *cNew )
{
    return -1 ;
}


Seems to fix the problem.

cmaglie

fat16lib,

thank you for the fix i'll include it in the coming 1.5.1. If you want to open a pull request for it would be great otherwise, if you don't care, i'll commit the fix by myself.

C
C.

Go Up