• AVR Freaks

Hot!MCC Generated code has errors in compile

Author
JohnWill
Starting Member
  • Total Posts : 65
  • Reward points : 0
  • Joined: 2012/07/01 09:36:18
  • Location: 0
  • Status: offline
2020/10/01 12:19:29 (permalink)
5 (1)

MCC Generated code has errors in compile

I'm using MPLABX-x 5.40 and XC8 2.30.
 
I started a new stand-alone project and used MCC to set up the I/O configuration.  I've included the main.c and the myConfig.mc3 files as attachments.
 
I get the following warnings when I compile it.
 
mcc_generated_files/tmr0.c:87:: warning: (520) function "_TMR0_ReadTimer" is never called
mcc_generated_files/tmr0.c:102:: warning: (520) function "_TMR0_Reload" is never called
mcc_generated_files/pin_manager.c:91:: warning: (520) function "_PIN_MANAGER_IOC" is never called
 
It seems to me that I shouldn't get this, it hasn't happened with older versions of code and compilers.

Attachment(s)

Attachments are not available: Download requirements not met
#1

6 Replies Related Threads

    Jim Nickerson
    User 452
    • Total Posts : 6752
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: MCC Generated code has errors in compile 2020/10/01 12:33:01 (permalink)
    0
    Those are warnings not errors.
    If you wish to get rid of them call the mentioned routines from your code
    #2
    JohnWill
    Starting Member
    • Total Posts : 65
    • Reward points : 0
    • Joined: 2012/07/01 09:36:18
    • Location: 0
    • Status: offline
    Re: MCC Generated code has errors in compile 2020/10/01 12:45:27 (permalink)
    0
    I realize they're warnings, I just never saw those come up previously using MCC.  Is this normal for the new versions of compiler and MPLAB?
     
    FWIW, the code runs, and those functions didn't seem to impact me when I looked, just wondered why they suddenly popped up.
    #3
    Mysil
    Super Member
    • Total Posts : 3796
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: MCC Generated code has errors in compile 2020/10/01 13:06:00 (permalink)
    +2 (2)
    Hi,
    Messages you have shown are Warnings, not errors.
     
    Warning levels are options that may be changed in MPLAB X 'Project Settings'
    for the compiler that is beeing used.
     
    Later versions of the compiler, and the standard specifying C language,
    is more specific about warning messages to be issued at different warning levels.
     
    MCC is creating a number of 'may be useful / may be nice to have'  functions
    as part of project source code.
    But MCC does Not know wether these functions will be actually used in application code.
     
    Since these functions are part of project, and not contained in a linkable library,
    Compiler will issue a warning that there are some functions in source code,
    that are not beeing used.
    Since this might possibly be caused by a misspelling, duplication or other mistake in source code,
    it is seen as something the programmer should be made aware of.
    Thus the warning.
     
    If you want to, when programming is complete, and ready for testing,
    you may go thru the list of warnings, and either comment out, or remove those functions that are not used.
     
    Although, some program developers use the following program development rules:
    "Test what you fly and fly what you have tested."
     
        Mysil
    #4
    JohnWill
    Starting Member
    • Total Posts : 65
    • Reward points : 0
    • Joined: 2012/07/01 09:36:18
    • Location: 0
    • Status: offline
    Re: MCC Generated code has errors in compile 2020/10/01 13:54:53 (permalink)
    0
    That makes sense, I may just put some dummy calls into quiet the complaints.  I'm loath to start changing the MCC generated code unless there's a reason.
     
    Thanks, I guess that's the price up upgrading the compilers. :)
     
    #5
    davekw7x
    Entropy++
    • Total Posts : 1891
    • Reward points : 0
    • Joined: 2012/01/16 12:01:07
    • Location: Second star on the right, straight on till morning
    • Status: offline
    Re: MCC Generated code has errors in compile 2020/10/01 19:06:51 (permalink)
    -1 (1)
    JohnWill
    ... may just put some dummy calls..

    Or you could put the following somewhere in one of your .c files.  To get cleaner compiles I usually put that directive near the top of main.c but it really doesn't matter where you put it (I think).

    #pragma warning disable 520

     
    Note that there are sections on how to eliminate spurious warnings in current XC8 User Guides (in the docs directory of the installation tree)
     
    Regards,

    Dave
    post edited by davekw7x - 2020/10/01 19:16:41

    Sometimes I just can't help myself...
    #6
    JohnWill
    Starting Member
    • Total Posts : 65
    • Reward points : 0
    • Joined: 2012/07/01 09:36:18
    • Location: 0
    • Status: offline
    Re: MCC Generated code has errors in compile 2020/10/02 05:43:11 (permalink)
    0
    Disabling the warning is an option, but the warning might be useful in a larger application.  This one only has a couple hundred lines, so I don't think I missed calling any important functions. :) 
    #7
    Jump to:
    © 2020 APG vNext Commercial Version 4.5