• AVR Freaks

C30 v3.25: What's with #pragma printf_check?

Author
aschen0866
Super Member
  • Total Posts : 4496
  • Reward points : 0
  • Joined: 2006/01/08 22:18:32
  • Location: San Diego
  • Status: offline
2010/11/15 16:39:20 (permalink)
0

C30 v3.25: What's with #pragma printf_check?

I am getting a whole bunch of "warning: ignoring #pragma printf_check" messages:

C:/Program Files/Microchip/MPLAB C30/include/stdio.h:167: warning: ignoring #pragma printf_check 
C:/Program Files/Microchip/MPLAB C30/include/stdio.h:168: warning: ignoring #pragma printf_check 
C:/Program Files/Microchip/MPLAB C30/include/stdio.h:205: warning: ignoring #pragma printf_check 
C:/Program Files/Microchip/MPLAB C30/include/stdio.h:206: warning: ignoring #pragma printf_check 


 and then the linker failure:

c:/program files/microchip/mplab c30/bin/bin/../../lib\libc-coff.a(vsnprintf.o)(.libc.vsnprintf+0x1e):fake: undefined reference to `assert'
c:/program files/microchip/mplab c30/bin/bin/../../lib\libc-coff.a(vsnprintf.o)(.libc.vsnprintf+0x22):fake: undefined reference to `alloc'
Link step failed.


The project was okay with the previous v3.24. I also tried to use -legacy-libc command line option, but it didn't seem to change anything.  This is my current compiler command line: -fshort-enums -g -Wall -D_ADDED_C_LIB -mlarge-code -Os -mpa

-D_ADDED_C_LIB was added so that I could use vsnprintf().

What am I missing here?

post edited by aschen0866 - 2010/11/15 16:41:12
#1

13 Replies Related Threads

    MikeWazowski
    New Member
    • Total Posts : 19
    • Reward points : 0
    • Joined: 2010/08/13 14:07:33
    • Location: 0
    • Status: offline
    Re:C30 v3.25: What's with #pragma printf_check? 2010/11/15 19:20:17 (permalink)
    0
    I'd say that if you're libraries are not working, you should revert to the original libraries with the -legacy-libc option like you said.

    I may be wrong about this, but I do not see any native support for the -legacy-libc option with MPLAB. This makes things tricky since MPLAB compiles and then links. The option should be passed to the compiler when it's linking all the object files, but I don't think that's possible (please tell me if you know how to do so).

    What -legacy-libc does is pass to the linker a set of libraries, which you can easily do by hand. Just add something like this " -( -llega-c-coff -lm-coff -llega-pic30-coff -) " to the MPLAB LINK30 command line under project -> build options and it should build. 


    edit: This is the hard way of doing things. Indeed the README.html says this about using -legacy-libc:
    add /include/lega-c to your include search path and add liblega-c-.a and liblega-pic30-.a to your list of libraries

    post edited by MikeWazowski - 2010/11/23 15:37:11
    #2
    cawilkie
    Administrator
    • Total Posts : 1977
    • Reward points : 0
    • Joined: 2003/11/07 12:49:11
    • Status: offline
    Re:C30 v3.25: What's with #pragma printf_check? 2010/11/16 09:49:25 (permalink)
    0
    The new libc is completely different from the old one.  I should have noted in the migration notes that one should completely rebuild.  For example, assert() is a macro in the new libc but was a function call in the old one.

    I believe the migration notes state that the current IDE does not support the -legacy-libc option, and how to configure the IDE to use the old libraries if needed.

    There is some missing functionality in the new library, but not in the mainstream areas.  Shall I put a list together?

    Regards
    Calum

    #3
    flubydust
    Super Member
    • Total Posts : 1286
    • Reward points : 0
    • Joined: 2005/05/19 13:44:42
    • Status: offline
    Re:C30 v3.25: What's with #pragma printf_check? 2010/11/16 10:12:29 (permalink)
    0
    cawilkie
    The new libc is completely different from the old one.


    Anyone with a Hi-Tech compiler will recognise where the new library came from.

    So what are the chances of getting source code for all/some of the library now?



    #4
    frankcf1
    Super Member
    • Total Posts : 1105
    • Reward points : 0
    • Joined: 2009/01/09 08:20:10
    • Location: Northern New Jersey
    • Status: offline
    Re:C30 v3.25: What's with #pragma printf_check? 2010/11/16 10:39:07 (permalink)
    0
    Please put a list together of missing functionality. It could save hours of frustration.
    Thanks,
    Frank
    #5
    aschen0866
    Super Member
    • Total Posts : 4496
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re:C30 v3.25: What's with #pragma printf_check? 2010/11/16 10:49:29 (permalink)
    0
    cawilkie

    The new libc is completely different from the old one.  I should have noted in the migration notes that one should completely rebuild.  ...
     
    Calum,
    How do I rebuild the new libc? I ran makelib.bat but I didn't see any new .a file being generated. Also, how many other libraries does a user have to rebuild himself? Kind of lost on why I have to do all these since I did a complete install of v3.25...


    #6
    nice
    Super Member
    • Total Posts : 1089
    • Reward points : 0
    • Joined: 2004/09/18 11:42:25
    • Location: Germany
    • Status: offline
    Re:C30 v3.25: What's with #pragma printf_check? 2010/11/16 11:18:20 (permalink)
    0
    cawilkieShall I put a list together?

    Yes, I'd very much appreciate it if you provide a list.

    Best regards,
    Bernd

    #7
    cawilkie
    Administrator
    • Total Posts : 1977
    • Reward points : 0
    • Joined: 2003/11/07 12:49:11
    • Status: offline
    Re:C30 v3.25: What's with #pragma printf_check? 2010/11/16 11:42:48 (permalink)
    0
    aschen0866

    cawilkie

    The new libc is completely different from the old one.  I should have noted in the migration notes that one should completely rebuild.  ...
     
    Calum,
    How do I rebuild the new libc? I ran makelib.bat but I didn't see any new .a file being generated. Also, how many other libraries does a user have to rebuild himself? Kind of lost on why I have to do all these since I did a complete install of v3.25...


    You only have to rebuild your code.

    Yes this means that we will be able to distribute the source of libc, once everything is more uniform.  We are planning on using the same libc across all families, which is a part of improving the portability across platforms.

    Regards
    Calum
    #8
    aschen0866
    Super Member
    • Total Posts : 4496
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re:C30 v3.25: What's with #pragma printf_check? 2010/11/18 10:54:07 (permalink)
    0
    Calum,
    Rebuilding my project does not silence the warning, nor does it fix the link failure regarding the use of vsnprintf(). Any thoughts?
    #9
    aschen0866
    Super Member
    • Total Posts : 4496
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re:C30 v3.25: What's with #pragma printf_check? 2010/11/18 12:51:22 (permalink)
    0
    Additional information on the #pragma printf_check warning messages:

    If I install C30 v3.25 with the default install directory, that is,

    c:\Program Files\Microchip\mplabc30\v3.25

    then I don't get any of those #pragma printf_check warnings.

    If I install the compiler with the more traditional Microchip approach, that is,

    c:\Program Files\Microchip\MPLAB C30

    then I get #pragram printf_check warnings every time when the file stdio.h is included. 

    In both cases, the linker failure is always there complaining about vsnprintf() as indicated in my first post.


    It seems if I have a project that was originally created with previous MPLAB and C30, I have these lines in the .mcp file:

    [PATH_INFO]
    BuildDirPolicy=BuildDirIsSourceDir
    ...
    dir_inc=.;C:\Program Files\Microchip\MPLAB C30\support\h\peripheral_24F;C:\Program Files\Microchip\MPLAB C30\include
    dir_lib=C:\Program Files\Microchip\MPLAB C30\lib
    ...


    And these two settings, dir_inc and dir_lib, will generate those #pragma pritnf_check warnings. 

    Test project attached.

    post edited by aschen0866 - 2010/11/18 14:25:21
    #10
    MikeWazowski
    New Member
    • Total Posts : 19
    • Reward points : 0
    • Joined: 2010/08/13 14:07:33
    • Location: 0
    • Status: offline
    Re:C30 v3.25: What's with #pragma printf_check? 2010/11/19 15:24:19 (permalink)
    0
    With regards to the vsnprintf, there are issues with the way it is defined.

    HiTech libs used to require that users define certain IO-functions like assert, putc, etc and that's why it can't find the definition.  As for the alloc it probably should be calling either malloc or alloca.  

    Until these changes are fixed you probably want to go with the old version of the libc

    #11
    aschen0866
    Super Member
    • Total Posts : 4496
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re:C30 v3.25: What's with #pragma printf_check? 2010/11/19 15:49:10 (permalink)
    0
    MikeWazowski
    ...
    HiTech libs used to require that users define certain IO-functions like assert, putc, etc and that's why it can't find the definition.  As for the alloc it probably should be calling either malloc or alloca.  
    ...
     
    That doesn't explain why vsprintf() compiles just fine. There is nothing in the stdio.h that says vsnprintf() requires any other functions being implemented first, but vsprintf() does not.



    #12
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11286
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re:C30 v3.25: What's with #pragma printf_check? 2010/11/19 16:56:02 (permalink)
    0
    I don't know if this helps, but the latest Hi-Tech library I have the source for (the 9.80 PICC compiler that was released recently) doesn't include the snprintf family of functions.  I've used some variant of this code with Hi-Tech projects when I needed snprintf:

    http://www.opensource.app...d/libnetbsd/snprintf.c
    #13
    aschen0866
    Super Member
    • Total Posts : 4496
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re:C30 v3.25: What's with #pragma printf_check? 2010/11/19 18:31:43 (permalink)
    0
    Thanks for the link. Interesting to see how involved it is to implement the real printf and his brothers and sisters.
    #14
    Jump to:
    © 2019 APG vNext Commercial Version 4.5