• AVR Freaks

Hot!XC8 Warning Messages

Author
rbuck
Super Member
  • Total Posts : 343
  • Reward points : 0
  • Joined: 2005/04/28 12:48:11
  • Location: Phoenix, AZ
  • Status: offline
2019/05/21 17:29:48 (permalink)
0

XC8 Warning Messages

I am running MPLAB X v5.10 with XC8 v2.05, running in C90 mode. I am receiving a couple of warning signs and would like to know why. PIC being used is PIC16F18877.

main.c:97:33: warning: (373) implicit signed to unsigned conversion
main.c:98:33: warning: (373) implicit signed to unsigned conversion
Line 97: red_led = !red_led;
Line 98: blue_led = !blue_led;

lcd.c:187:32: warning: (359) illegal conversion between pointer types
Line 186: LCDsendString("        "); <-- This is to write all spaces to LCD
 
My LCDsendString function is just passing this: void LCDsendString(char *buffer)
 
This $$!! website won't let me post the code. It gives the error message shown in my previous post.
 
post edited by rbuck - 2019/05/21 18:57:16
#1

13 Replies Related Threads

    katela
    Super Member
    • Total Posts : 1259
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: offline
    Re: XC8 Warning Messages 2019/05/21 17:45:19 (permalink)
    +1 (1)
    Are you using code tags? 
    Try to paste your code first to notepad to clear any formatting stuff, then copy from notepad and paste here and see if it will allow you to post the code.
    I guess you meant PIC16F18877 (with two 8)

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
    #2
    NKurzman
    A Guy on the Net
    • Total Posts : 17361
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: XC8 Warning Messages 2019/05/21 18:30:15 (permalink)
    +1 (1)
    What is red_led defined as?

    The second one my be the passing of a const
    Try const char *
    post edited by NKurzman - 2019/05/21 18:34:36
    #3
    rbuck
    Super Member
    • Total Posts : 343
    • Reward points : 0
    • Joined: 2005/04/28 12:48:11
    • Location: Phoenix, AZ
    • Status: offline
    Re: XC8 Warning Messages 2019/05/21 18:56:53 (permalink)
    0
    Are you using code tags?
    Tried it both with and without code tags. The code simply doesn't show up. When I try to post I get that error message. Yes, I meant PIC16F18877.
     
     
    What is red_led defined as?
    #define blue_led    LATDbits.LATD5
    #4
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: XC8 Warning Messages 2019/05/21 19:31:31 (permalink)
    +1 (1)
    Your code probably contains a function where the name ends with "char".
    The brain dead firewall on this web server triggers whenever it sees "char" followed by "(".
    You can change "char" to "chr" or put two spaces before the "(" to work around it.
     
    To avoid the second message, I think your function will have to be:
    LCDsendString(const char *buffer)
     

    Nearly there...
    #5
    1and0
    Access is Denied
    • Total Posts : 9252
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: XC8 Warning Messages 2019/05/21 19:56:42 (permalink)
    0
    Try these:

    red_led ^= 1;
    blue_led ^= 1;
     
    void LCDsendString(const char *buffer)

    #6
    rbuck
    Super Member
    • Total Posts : 343
    • Reward points : 0
    • Joined: 2005/04/28 12:48:11
    • Location: Phoenix, AZ
    • Status: offline
    Re: XC8 Warning Messages 2019/05/21 20:13:45 (permalink)
    0
    LCDsendString(const char *buffer);
    That got rid of the error message.
     
    Any idea about the blue_led?
     
    I also see this warning: lcd.c:80:17: warning: (373) implicit signed to unsigned conversion
    void LCDsendCmd(unsigned char ch) //Sends Char to LCD
    {
        unsigned char nibble;  
        nibble = ch >> 4;  // move high 4 bits to lower 4 bit position <------ This is line 80
     
    ch and nibble are both unsigned chars so I don't know why the error message is given. Somehow by shifting ch 4 positions it thinks there is a signed value involved.
     
    I didn't see these warnings until I switched from XC8 v4.15 to v5.10 a few days ago and told 5.10 to upgrade the project. May be better to just switch back to 4.15.
     
    #7
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: XC8 Warning Messages 2019/05/21 20:22:28 (permalink)
    0
    rbuck
    That got rid of the error message.

    As it should. You're not allowed to pass a "const" pointer to a function that doesn't promise to treat it as a const.
     

    Any idea about the blue_led?

    Try 1and0's suggestion.
     

    I also see this warning: lcd.c:80:17: warning: (373) implicit signed to unsigned conversion
    void LCDsendCmd(unsigned char ch) //Sends Char to LCD
    {
       unsigned char nibble;  
       nibble = ch >> 4;  // move high 4 bits to lower 4 bit position <------ This is line 80

    I'm not sure, but maybe try
     
       nibble = ch >> 4U;  // move high 4 bits to lower 4 bit position <------ This is line 80
     

    I didn't see these warnings until I switched from XC8 v4.15 to v5.10 a few days ago and told 5.10 to upgrade the project. May be better to just switch back to 4.15.

    Those are MPLABX version numbers, not XC8 versions.
    XC8 has recently transitioned from version 1.xx to 2.xx, and version 2 defaults to a new "C99" mode which has a LOT of differences. "C90" mode is still available.
    See: https://microchipdeveloper.com/xc8:whats-new-in-xc8-2-0
    and: https://microchipdeveloper.com/xc8:moving-to-xc8-2-0
     

    Nearly there...
    #8
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11188
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: XC8 Warning Messages 2019/05/21 22:09:59 (permalink)
    +1 (1)
    ch and nibble are both unsigned chars

     
    Like most operators, the shift operators apply the integer promotions, so the result of your shift is a signed int.
    #9
    rbuck
    Super Member
    • Total Posts : 343
    • Reward points : 0
    • Joined: 2005/04/28 12:48:11
    • Location: Phoenix, AZ
    • Status: offline
    Re: XC8 Warning Messages 2019/05/21 23:42:33 (permalink)
    0
    Thanks everyone for the comments.
     
    Those are MPLABX version numbers, not XC8 versions

    Got in too big of a hurry. I meant to say v1.45 to v2.05
     
    Like most operators,.....

    Changing ch and nibble to signed char makes the warning go away.
     
    version 2 defaults to a new "C99" mode

    :279:6: error    LCDclr;
    : variable has incomplete type 'void'

    main.c:279:15: error: expected ';' after top level declarator
    void interrupt all_ints (void)
    #10
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: XC8 Warning Messages 2019/05/21 23:48:05 (permalink)
    +1 (1)
    The syntax for the interrupt qualifier changed in v2.xx.
    It's described in those articles I linked to.
     

    Nearly there...
    #11
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11188
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: XC8 Warning Messages 2019/05/22 09:59:56 (permalink)
    +2 (2)
    Changing ch and nibble to signed char makes the warning go away.

     
    I wouldn't recommend shifting signed values; that can have unexpected side effects.  This will keep everything unsigned and no warning:
    nibble = (uint16_t)ch >> 4U;

    #12
    rbuck
    Super Member
    • Total Posts : 343
    • Reward points : 0
    • Joined: 2005/04/28 12:48:11
    • Location: Phoenix, AZ
    • Status: offline
    Re: XC8 Warning Messages 2019/05/22 17:42:19 (permalink)
    0
    nibble = (uint16_t)ch >> 4U;

    This works.
     
    blue_led ^= 1;  <--- This is line 132
    main.c:132:: advisory: (1395) notable code sequence candidate suitable for compiler validation suite detected (342)
    #13
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11188
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: XC8 Warning Messages 2019/05/22 17:45:47 (permalink)
    +1 (1)
    notable code sequence candidate suitable for compiler validation suite detected

     
    I'm pretty sure that will be explained in the manual, and in numerous posts on the forum.
    #14
    Jump to:
    © 2019 APG vNext Commercial Version 4.5