Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: sscanf() problems on Teensy 3.0 & Windows

  1. #1
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    461

    Question sscanf() problems on Teensy 3.0 & Windows

    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 ?

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,674

    Cool

    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
    (hmmm, too bad this forum doesn't have :nerd:, oh well).

  3. #3
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    461
    Quote Originally Posted by MichaelMeissner View Post
    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
    (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 ?

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,817
    I've added these, so the sprintf and sscanf should work on the next beta release.

    I'm looking into other issues snprintf now.... followup here:

    http://forum.pjrc.com/threads/710-Te...ring-functions

  5. #5
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    461
    Is there a reason why it works OK on my Mac, but not on the PCs ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •