Pages: [1]   Go Down
Author Topic: Incorrect type for link() in syscalls.h prevents use of unistd.h  (Read 636 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Edison Member
*
Karma: 44
Posts: 1471
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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:
extern int link(const  char *cOld, const char *cNew ) ;

And the implementation in syscalls_sam3.c to this:
Code:
extern int link(const char *cOld, const char *cNew )
{
    return -1 ;
}

Seems to fix the problem.
Logged

Forum Administrator
Milano, Italy
Offline Offline
Sr. Member
*****
Karma: 22
Posts: 291
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

C.

Pages: [1]   Go Up
Jump to: