• AVR Freaks

Hot!Type issues migrating from a pic16f1937 to a pic18f47k42 project

Author
JustRob
Super Member
  • Total Posts : 439
  • Reward points : 0
  • Joined: 2008/09/04 12:49:27
  • Location: 0
  • Status: offline
2019/07/20 12:25:28 (permalink)
0

Type issues migrating from a pic16f1937 to a pic18f47k42 project

I'm using MPLabX v5.15, the XC8 v2.05 compiler with the ICD3 debugger.
 
The pic18(l)f47k42 is a pin to pin compatible device with the pic16(l)f1937.
 
I created a new project and adding files files from the pic16f1937 project.  I know there are a slew of register differences but I would have thought the data types would be the same.
 
I'm getting unknown type errors for every uint8_t and uint16_t types that I use.  I looked at the XC8 compiler documentation and it looks like the type is unsigned char.  Does this mean I have to change all of the uint8_t variable definitions to unsigned char variables?  And with the uint16_t...
#1

7 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 2893
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Type issues migrating from a pic16f1937 to a pic18f47k42 project 2019/07/20 13:24:01 (permalink)
    +1 (1)
    Hi Rob,
     
    do you #include <stdtypes.h> ?
    Not sure why the uintX_t types may have worked on the PIC16 (my PIC16 experience is that stdtypes.h is required) ...

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    JustRob
    Super Member
    • Total Posts : 439
    • Reward points : 0
    • Joined: 2008/09/04 12:49:27
    • Location: 0
    • Status: offline
    Re: Type issues migrating from a pic16f1937 to a pic18f47k42 project 2019/07/20 14:12:46 (permalink)
    0
    I see stddef.h but no stdtypes.h.  Can you tell me where in XC8>2.05 it is?  I searched for it with no luck.
     
    Not sure why the uintX_t types may have worked on the PIC16

     
    I use to include GenericTypeDefs.h but The compiler had all kinds of errors with redefined types like "BIT" so I unincluded that and changed all of my UINT(X) to uintX_t but I'm still getting a ton of errors.
    #3
    du00000001
    Just Some Member
    • Total Posts : 2893
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Type issues migrating from a pic16f1937 to a pic18f47k42 project 2019/07/20 14:55:29 (permalink)
    +2 (2)
    Ah.
    Forcing the compiler to c90 instead the now defaulting c99 might have eliminated these errors as well.
     
    Sorry to say, my recall was imperfect: should be <stdint.h>  😔

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #4
    JustRob
    Super Member
    • Total Posts : 439
    • Reward points : 0
    • Joined: 2008/09/04 12:49:27
    • Location: 0
    • Status: offline
    Re: Type issues migrating from a pic16f1937 to a pic18f47k42 project 2019/07/20 15:13:27 (permalink)
    0
    I was just getting on to say I found that and included it in my main file.  It seems to have worked.
     
    Thanks!
    #5
    du00000001
    Just Some Member
    • Total Posts : 2893
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Type issues migrating from a pic16f1937 to a pic18f47k42 project 2019/07/20 15:23:13 (permalink)
    0
    The intX_t/uintX_t types are really worth this bit of trouble - making "things" way clearer than the original C data types.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #6
    JustRob
    Super Member
    • Total Posts : 439
    • Reward points : 0
    • Joined: 2008/09/04 12:49:27
    • Location: 0
    • Status: offline
    Re: Type issues migrating from a pic16f1937 to a pic18f47k42 project 2019/07/20 15:47:40 (permalink)
    0
    Agreed!
    #7
    InvalidApple
    Super Member
    • Total Posts : 296
    • Reward points : 0
    • Joined: 2011/05/17 23:36:35
    • Location: Melbourne, Australia
    • Status: offline
    Re: Type issues migrating from a pic16f1937 to a pic18f47k42 project 2019/07/28 17:14:39 (permalink)
    +1 (1)
    uintN_t is defined in stdint.h
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5