sscanf() problems on Teensy 3.0 & Windows

Jp3141

Well-known member
This minimal example won't compile on Win7 or WinXP, but works on my Mac:

Code:
int i;
void setup() {}
void loop() {sscanf("0", "%d", &i);}

This is the error:

c:/projects/arduino-1.0.2/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-closer.o): In function `_close_r':
closer.c.text+0x12): undefined reference to `_close'
c:/projects/arduino-1.0.2/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c.text+0x16): undefined reference to `_lseek'
collect2: ld returned 1 exit status


I had posted this in the other forum, but got little response. #include'ing the stdio.h and/or stdlib.h doesn't make any difference. Anyone have a solution ?
 
Obviously, the best solution is to fix the library, but until it is fixed, you could add something like the following to your main program:

Code:
#ifdef __arm__
extern "C" {
int _close (int fd) { return -1; }
int _lseek (int fd, long long offset, int whence) { return -1; }
};
#endif

:cool: (hmmm, too bad this forum doesn't have :nerd:, oh well).
 
Obviously, the best solution is to fix the library, but until it is fixed, you could add something like the following to your main program:

Code:
#ifdef __arm__
extern "C" {
int _close (int fd) { return -1; }
int _lseek (int fd, long long offset, int whence) { return -1; }
};
#endif

:cool: (hmmm, too bad this forum doesn't have :nerd:, oh well).

Thanks, that sort of fixes it (I guess it basically makes those calls ignored; that can't be the desired action), but the tiny sketch (your #ifdef + my example above) then compiles to 46,268 bytes; something is wrong.

Also, aren't the Arduino libraries identical across platforms ? Why is this fix not necessary on my Mac ?
 
Back
Top